#include #include #include #define MAX 10 // max char per line // the code looks more idomatic but other edge case lurk. // can you find them? int main(void) { int i; char s[MAX]; // note, we use the idomatic for loop with i++ and not ++i as // in the edgecases.c for (i = 0; i < MAX-1; i++) { if ((s[i] = getchar()) == '\n') break; printf("s[%d]=%c\n", i, s[i]); } s[i] = '\0'; printf("string is %s\n", s); return 0; }