int iarray[] = {1,2,3,4,5}; char string[] = "abcde" |
#include <stdio.h> int main (void) { char string[80]; int length; printf ("Enter a string: "); scanf ("%s", string); length = strlen (string); printf ("You entered %d characters.\n", length); return 0; } |
scanf ("%s", string); |
int FindMonthNum (const char *monthName) { if (strcmp (monthName, "January") == 0) return 1; else if (strcmp (monthName, "February") == 0) return 2; else if (strcmp (monthName, "March") == 0) return 3; else if (strcmp (monthName, "April") == 0) return 4; else if (strcmp (monthName, "May") == 0) return 5; else if (strcmp (monthName, "June") == 0) return 6; else if (strcmp (monthName, "July") == 0) return 7; etc. |
int FindMonthNum (const char * monthName) { int i; char *month[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; for (i = 0; i < numMonths; ++i) if (strcmp (monthName, month[i]) == 0) return i+1; return 0; } |
int getchar(void); |
int putchar(int ch); |
main() { int c; c = getchar(); while(c != EOF) { putchar(c); c = getchar(); } return 0; } |
while((c = getchar()) != EOF) putchar(c); |
(c = getchar()) |