读书人

存txt文件有关问题

发布时间: 2012-02-28 13:06:36 作者: rapoo

存txt文件问题
想存在txt中的形式为:
200702051001001 10:10 00010 10001 01001 10000 00000 00000
200702051001002 10:20 00000 00001 00000 00000 00000 00100

但是在存入后:
200702051001001 10:10 000101000101001100000000000000

200702051001001存在字符数组strid中
时间(10:10)存在字符数组strtime中
后面的存在字符数组strnum[5][4]中
请问怎么处理???

[解决办法]
FILE *fp;
fp = fopen( "a.txt ", "w ");
for (int i=0; i <5; i++)
{
CString temp;
temp.Format( "%s ", strid);
temp += " ";
temp += strtime;
for (int j=0; j <4; j++)
{
temp += " ";
temp += strnum[i][j];
}
fputs(temp, fp); //格式忘了,差不多
}

这样应该就可以了

读书人网 >C语言

热点推荐