fscanf problem

4 Ansichten (letzte 30 Tage)
oblivious
oblivious am 19 Mai 2012
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

Antworten (1)

Walter Roberson
Walter Roberson am 19 Mai 2012
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 %[ )

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by