Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C Cygwin
how can I do this condition between client and server
in data.txt I have these username
in server.c
I write this before main
typedef struct
   int    name;
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
				printf("you are here");
			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
johny10151981 at 25-Dec-11 20:03pm
Whey does it says that argument 2 is integer?? is inputQ[i].name integer

1 solution

Rate this: bad
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)
malemar at 26-Dec-11 6:55am
thank you
this code solved my problem
Chuck O'Toole at 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)

Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 25 Dec 2011
Copyright © CodeProject, 1999-2015
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