Checking a string for a certain character

Posted by Zeno on Mon 01 Nov 2004 05:17 PM — 4 posts, 17,584 views.

USA #0
Is there any sort of function or linux command that would check a string for a certain character? For example:
strchk( buf, "death" );

Would check the buffer 'buf' for "death". Does Smaug or linux have anything like that? If not, how would I got about doing that? Basically, I want to check a pcdata string for if it has the characters name in it.
Canada #1
You can use the strstr function, like such
strstr(buf, "death")

It returns true if the second argument is found in the first.
Amended on Mon 01 Nov 2004 05:29 PM by Greven
USA #2
Thanks, although it is case sensitive. Should I follow how Smaug did str_cmp? (Where was that defined?)

[EDIT] str_str seems to already exist in grub.c
Amended on Mon 01 Nov 2004 05:39 PM by Zeno
USA #3
Look into strcasestr.