c++如何用scanf读入汉字串??
我的问题是如何从文件中读入汉字串?
我用
char names[100][100];
for(int i=0;i <100;i++)
scanf( "%s ",names[i]);
发现读入不了,而且会产生中断信息,为什么呢?
要怎么解决哦?
谢谢~~~
[解决办法]
#include <stdio.h> #include <stdlib.h>
int main(int argc, char **argv)
{
FILE *fp=fopen( "test.txt ", "r ");
char names[10][100];
for(int i=0;i <10;i++)
fscanf(fp, "%s ",names[i]);
for(int i=0;i <10;i++)
puts(names[i]);
system( "pause ");
return 0;
}
test.txt 文件内容:
我的论坛
我的问题
我参与的问题
我得分的问题
我的信誉分
我的收藏夹
短信息
使用帮助
我要投诉
我的论坛