1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define N 10 5 6 int main() 7 { 8 char a[N]; 9 char * p; 10 11 printf("input string:\n"); 12 fgets(a,sizeof(a),stdin); 13 14 if ((p=(strchr(a,'\n')))!=NULL)/*fgets不会像gets那样自动地去掉结尾的\n,所以程序中手动将\n位置处的值变为\0,代表输入的结束。*/ 15 { 16 *p=0; 17 } 18 19 printf("string is:\n%s",a); 20 21 return 0; 22 }
fgets()
猜你喜欢
转载自www.cnblogs.com/hemeiwolong/p/9095942.html
今日推荐
周排行