Click here to Skip to main content
12,075,542 members (66,764 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C Cygwin
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 25-Dec-11 13:10pm
malemar377
Comments
johny10151981 25-Dec-11 20:03pm
   
Whey does it says that argument 2 is integer?? is inputQ[i].name integer

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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)
...
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 25 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100