fscanf problem

1 visualizzazione (ultimi 30 giorni)
oblivious
oblivious il 19 Mag 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

Risposte (1)

Walter Roberson
Walter Roberson il 19 Mag 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 %[ )

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by