PDA

View Full Version : Fread problem.


Youice
25/01/2013, 05:52 PM
hello, there,

Can any one figure why I have these problems?


stock CheckContacts(playerid)
{
new contact[128];
new str[128];
new temp = strlen(str) >= 10;
for(new i = 0; i<MAX_PLAYERS; i++)
{
format(contact, 128,"LV-RP/%s/Contacts/%s.ini", GetPlayerNameEx(playerid), i);
new File:file = fopen(contact, io_read);
while(fread(contact, str))//error 035: argument type mismatch (argument 1)
{
if(strcmp(file, temp, true) == 0)//error 035: argument type mismatch (argument 2)
{
return 1;
}
else {
return 0;
}
}
}
return 1;
}


Errors/warnings

error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
warning 204: symbol is assigned a value that is never used: "file"
warning 204: symbol is assigned a value that is never used: "temp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


Note: I tagged the errors in the code

IPrototypeI
25/01/2013, 07:51 PM
I hope you know what argument type mismatch (argument 1) means .
you used fread wrong where is the file directory

while(fread(contact, str)) <= wrong

while(fread(file, str)) <= right

the same there
if(strcmp(file, temp, true) == 0)

you can`t use file there use str you get the which you read out of the file in this string

and rethink more about your code i don't understand what do you want to check.

Roach_
25/01/2013, 07:54 PM
Try this:
stock CheckContacts(playerid)
{
new contact[128];
new str[128];
new temp = strlen(str) >= 10;
for(new i = 0; i<MAX_PLAYERS; i++)
{
format(contact, 128,"LV-RP/%s/Contacts/%s.ini", GetPlayerNameEx(playerid), i);
new File:file = fopen(contact, io_read);
while(fread(file, str))
{
if(strcmp(file, str, true, temp)) return 0;
}
}
return 1;
}