sscanf question

Hi Guys,

Variable str contains this

304 ttys000 0:00.06 -bash


Now in code
1
2
3
4

sscanf(str, "%d %[^/]/%d %d:%d:%d %s", &pid, tty, &n, &hr, &min, &sec, ccmd);
printf("pid = %d, tty = %s, n = %d, hr = %d, min = %d, sec = %d, ccmd = %s\n", pid, tty, n, hr, min, sec, ccmd);


Can someone please explain me what is the meaning of
%[^/]/%d
above?

Thanks in advance
Last edited on
http://linux.die.net/man/3/sscanf

See down near the bottom between the c and p conversion specifiers.
Ahhaa. Thanks Duoas. I think I got it now except for one thing.

So
%[
matches any character. And
[^
excludes any character listed inside
[
Now what I don't understand is that why do we have to use
^/]/
. Is there any special meaning to / in the above context?
Last edited on
Topic archived. No new replies allowed.