strfind wont work.
#1

hey. i just worte string into file and i tryed to look for some string in the file with strfind.
and it dosent found that.
pb:
http://pastebin.com/RQ697SMN
it fails to find "2" in the string. but its find 1. help?
Reply
#2

help?
Reply
#3

fread(fh, str); reads only 1\r\n - one line

pawn Код:
new File:fh = fopen("text.txt",io_read);
    new line;
    while(fread(fh, str))
    {
        ++line;
        if(strfind(str,"2",true) != -1)
        {
            printf("succeed at line %d",line);
            break; // stops the loop
        }
        else print("failed");
    }
    fclose(fh);
Reply
#4

Quote:
Originally Posted by Jefff
Посмотреть сообщение
fread(fh, str); reads only 1\r\n - one line

pawn Код:
new File:fh = fopen("text.txt",io_read);
    new line;
    while(fread(fh, str))
    {
        ++line;
        if(strfind(str,"2",true) != -1)
        {
            printf("succeed at line %d",line);
            break; // stops the loop
        }
        else print("failed");
    }
    fclose(fh);
wow thanks.
but i want to break the loop, and also return 1;
how may i do that?
Reply
#5

look i have few strings, and it still dosent find them.
those strings:
ARTPEPEPEPE
ARTTTTTTTT
ARPEERERERR

i want it to recognize the second.
but it wont.
help?
Reply
#6

pawn Код:
new File:fh = fopen("text.txt",io_read);
new Found;
while(fread(fh, str))
    if(strfind(str,"2",true) != -1)
    {
        Found = 1;
        break; // stops the loop
    }

fclose(fh);
return Found; // returns 0 if not found or 1 if match
Reply
#7

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
new File:fh = fopen("text.txt",io_read);
new Found;
while(fread(fh, str))
    if(strfind(str,"2",true) != -1)
    {
        Found = 1;
        break; // stops the loop
    }

fclose(fh);
return Found; // returns 0 if not found or 1 if match
thanks alot!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)