Click here to Skip to main content
Rate this: bad
good
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 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
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 at 26-Dec-11 6:55am
   
Yes
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 535
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


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