Originally Posted by
dwks
May be that will work, probably will actually buit I already have done this in the meantime.
(the string being searched is in var2.) Should I use EOF or EOL or \0 or what?
Code:
int a1;
for(a1=0; var2[a1]!=EOF; a1++)
{
if(var2[a1]=='w' {
if (strcmp(&var2[a1],"won" ==0) {
printf("\n FOund it!! %s won, player");
break;
}
}
}
Or just to explain that segment more with more of the code, the initial string is in var1.
Code:
sscanf(var1,"Seat %d: %s %[^\n]\n",&seatnum,player,var2);
{
int a1;
for(a1=0; var2[a1]!=EOF; a1++)
{
if(var2[a1]=='w' {
if (strcmp(&var2[a1],"won" ==0) {
printf("\n FOund it!! %s won, player");
break;
}
}
}
}
So basically I just search for a 'w' and then do a strcmp for "won" that should do the trick
Strstr is probably better, actually now I have read the description of it it is ideal!
I will use strstr if my code fails!! (probably will!!).
I don't know the libaries very well, I probably should but usually find it quicker to write the
code myself than search for the correct function!! However in the long run it would be better
to know the libaries!!
Thanks for your help!!!