scanf problem

T

thomas

Once I saw some code like this.

---code--
char pid[8];
char url[1001];
char url2[873];
while ( scanf("\"%[^\"]\",\"%[^\"]\",\"%s\n", pid, url, url2) > 0 ) {
//blabla
}
----code---

There are a lot of messy formating things in the scanf call.
While there is only one "%s" input specifier, can it work to fill the
three strings?
 
T

thomas

thomas said:
---code--
char pid[8];
char url[1001];
char url2[873];
while ( scanf("\"%[^\"]\",\"%[^\"]\",\"%s\n", pid, url, url2) > 0 ) {
//blabla
}
----code---
There are a lot of messy formating things in the scanf call.
While there is only one "%s" input specifier, can it work to fill the
three strings?

%[] is also a conversion specifier.http://www.opengroup.org/onlinepubs/000095399/functions/fscanf.html

Good! I've never noticed such usage of scanf. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,417
Latest member
DarrenGaun

Latest Threads

Top