Re: Non case-sensitive chat commands? [message #367897 is a reply to message #367682] |
Mon, 19 January 2009 05:10 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma:
|
General (3 Stars) |
|
|
In sscanf, %[] means "everything" the '^' character means "except this"
%[^g] would mean everything except 'g' %[\n] means everything except '\n'. You can also combine them, %[^\ngasd] "everything except '\n','g','a','s','d'"
If you don't have the '^' character you can use it to match "specific" characters.
%[abcd] would only match 'a','b','c','d'
%s in sscanf means a word, so it will stop reading when it meets whitespace or a newline. Not sure on the exact characters it actually reads.
scanf returns the number of variables matched, so we want 2 vars out of the string, we use == 2 or >1 to make sure it succeeded.
Lastly, whitespace in the format string means "whitespace" and not a single space.
sscanf("hello world!", "%s %s", hello, world) //fill hello and world
This applies to everything
sscanf("123 321", "%d %d", &i, &u) //123 321
stricmp is non-case sensitive.
|
|
|