Strings - fflush(stdin); printf("Please enter your...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* This program demonstrates strings */ #include<stdio.h> //standars input/output functions void main() { char name[20]; //allows 19 chars, ending w/ null \0 int test; //whole numbers from -32768 to 32767 (16 bits) printf("Please enter your full name "); //print on screen //scanf("%s",name); //(reads up to whiteapace) //%d=int placeholder %s=string placeholder gets(name); //reads whole line printf("Please enter your test score "); scanf("%d",&test); printf("Your name is %s\n",name); printf("Your test score is %d\n\n",test);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fflush(stdin); printf("Please enter your full name "); gets(name); printf("Please enter your test score "); scanf("%d",&test); printf("Your name is %s\n",name); printf("Your test score is %d\n",test); } /* Please enter your full name john smith Please enter your test score 92 Your name is john smith Your test score is 92 Please enter your full name mark anderson Please enter your test score 95 Your name is mark anderson Your test score is 95 Press any key to continue . . . */...
View Full Document

This note was uploaded on 10/05/2011 for the course CS 36 taught by Professor Sethhochwald during the Spring '09 term at Irvine Valley College.

Ask a homework question - tutors are online