scanf メソッドのみに制限されたクラス用のプログラムを作成します。プログラム受信は、入力として任意の数の行を受信できます。scanf で複数行の入力を受け取る際の不具合。
#include <stdio.h>
int main(){
char s[100];
while(scanf("%[^\n]",s)==1){
printf("%s",s);
}
return 0;
}
入力例:
Here is a line.
Here is another line.
これは現在の出力です:
Here is a line.
出力を入力と同じにしたい。scanf を使用します。