過去ログ
No.574.scanf で this is a pen を読む
char buf[256];char c; int i; for(i=0;i<255 && c!='\n';i++){ scanf("%c",&c);buf[i]=c; } buf[i]='\0'; printf("%s",buf);
#include <stdio.h> int main(void) { char buf[256]; if (scanf("%255[^\n]", buf) == 1) puts(buf); return 0; }
i=0; while(buf[i]!='\0') { if(isspace(buf[i])) printf("\n"); else printf("%c",buf[i]); i++; }