C
c언어 scanf 로 문자열 입력받아 출력하기(띄어쓰기도 가능)
데브웅
2019. 6. 17. 00:20
s 옆에 [^\n]을 붙여 주면 문자열 띄어쓰기도 인식하여 출력해 준다.
1
2
3
4
5
6
7
8
9
10
|
#include <stdio.h>
int main()
{
char s1[30];
printf("input string: ");
scanf("%[^\n]s", s1);
printf("%s\n", s1);
return 0;
}
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs |