Rhent 发表于 2008-12-15 10:42

【求助】读入txt时如何不让空格丢失

程序段为:
fid1=fopen('input.txt','rt');
s=fscanf(fid1,'%s');
fclose(fid1);

加入input.txt中内容为:
Skip to content.Skip to bbc.co.uk navigation.Skip to bbc.co.uk search.The BBC is not responsible for the content of external internet sites.
结果为:
s=Skiptocontent.Skiptobbc.co.uknavigation.Skiptobbc.co.uksearch.TheBBCisnotresponsibleforthecontentofexternalinternetsites.

读入的txt文件为一段纯英文字符串,读入工作空间后空格丢失,用了多种读入函数(dlmread,fread等)均无法解决,请教高人。

sogooda 发表于 2008-12-15 12:39


>> fid1=fopen('input0.txt','rt');s=fgetl(fid1);fclose(fid1);
>> s

s =

Skip to content.Skip to bbc.co.uk navigation.Skip to bbc.co.uk search.The BBC is not responsible for the content of external internet sites.

ydlcsu 发表于 2008-12-15 13:09

fid1=fopen('input.txt','rt');
s=fscanf(fid1,'%c');%换个读取格式就行了
fclose(fid1);

Rhent 发表于 2008-12-15 14:20

非常感谢!!
页: [1]
查看完整版本: 【求助】读入txt时如何不让空格丢失