MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]读入txt时空格丢失问题 (https://www.labfans.com/bbs/showthread.php?t=5847)

Rhent 2008-12-15 10:40

[求助]读入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等)均无法解决,请教高人。

jiwasun 2008-12-16 11:19

回复: [求助]读入txt时空格丢失问题
 
是不是跟你选取的format,%s有关系,试试别的

feilove 2008-12-17 23:46

回复: [求助]读入txt时空格丢失问题
 
楼上说的对,把%s改为%c就可以了


fid1=fopen('input.txt','rt');
s=fscanf(fid1,'%c');
fclose(fid1);


所有时间均为北京时间。现在的时间是 06:12

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.