About Strcmp
#1

I am kinda confused with strcmp and getting the string from a file. I want to know if, I want to get a name from a string and compare it with the variable 'Name' and let it return that it is found, if I would use :

pawn Код:
strcmp(Name,dini_Get(file,"Name"),false,strlen(Name))
Or

pawn Код:
if(strcmp(dini_Get(file,"Name"),Name,false) == 0)
Asuming that in the file, Name=Tee.

I don't really understand the example on wiki samp about getting the string from a textfile and if it's found, would it return the length of the string?
Reply
#2

Your code appears to be correct, dini_Get is returning the string in the Name key of the ini file.

So your second example is correct and should work fine, have you tested it?
Reply
#3

I have been using it for quite a while and it works when it feels to. The other thing, if it is from a textfile (like .ini) for it to return found, would i use strval(stringfromvarialbe) or == 0 (as in the example at wiki samp).

String from variable would be 'Name'
Reply
#4

the

strcmp < Compares.


Mode 1:
pawn Код:
if(!strcmp(     dini_Get(file,"Name")     ,      Name,true))

Mode 2:
pawn Код:
if(!strcmp(          Nome,      dini_Get(file,"Name"),true))

the two modes is correct.
Reply
#5

So from a textfile, it does not matter wheather I put strval(stringfromvariable) or == 0?
Reply


Forum Jump:


Users browsing this thread: