2009年7月8日

C scanf to include white spaces


#include <stdio.h>

int main(int argc, char** argv) {
char strx [1024];
do {
strx[0] = '\0';
scanf("%[^\n]", strx);
if (!feof(stdin)) {
getchar();
}
printf("input: %s\n", strx);

} while (strx[0] != '\0');
printf("bye!\n");
return 0;
}

沒有留言:

網誌存檔