fscanf problem

4 ビュー (過去 30 日間)
oblivious
oblivious 2012 年 5 月 19 日
hello, this is a very simple problem. but i cant figure it out. i have a text file. it contains a line
'read this line'.
when i write a=fscanf(fid,'%c') it shows
a= read this line.
but when i write
a=fscanf(fid,'%c '),
with a space after %c, it shows
a=readthisline.
what happens when i put that space?
-obli

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 19 日
Inside input formats, any character which is given literally is a character that is to be matched against in input, and discarded when found. For example if you had a format of '%c<%c>' then the '<' and '>' would have to appear in the input and would be "eaten" and thrown away. The space character is not special in this regard (but it can often look like it because spaces and tabs and newlines at the beginning of a field are ignored for all formats other than %c and %[ )

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by