Click here to Skip to main content
15,888,190 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
how can I do this condition between client and server

in data.txt I have these username
11
22

in server.c
I write this before main
typedef struct
{
   int    name;
}client;
client inputQ[30];

then I receive username from client
now I want check if this username in data.txt file or not
my question is
how can I check that username in data.txt file or not

if(strcmp(buffer,inputQ[i].name)!=0)
			{
				printf("you are here");
			}
			else
			printf("you are not here");

buffer is what I received from the client

and I got this warning
warning: passing argument 2 of 'strcmp' makes pointer from integer without a cast
Posted
Comments
Mohibur Rashid 25-Dec-11 20:03pm    
Whey does it says that argument 2 is integer?? is inputQ[i].name integer

1 solution

You did not show the definition of buffer but I assuming it is an array of char or a char *. In either event, your name field of the struct is an int. You cannot use strcmp() to compare these two dissimilar types.

Either store the data from your file as chars or convert the incoming buffer contents to an int. Your choice.

int p = atoi(buffer);
if (p == inputQ[i].name)
...
 
Share this answer
 
v2
Comments
malemar 26-Dec-11 6:55am    
Yes
thank you
this code solved my problem
Chuck O'Toole 26-Dec-11 8:26am    
please 'accept' this answer so your problem will be marked as "solved"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900