473,513 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about function strcmp() in C

9 New Member
There is partial code in C
Expand|Select|Wrap|Line Numbers
  1. typedef struct message {
  2.     int messageId;
  3.     char *messageText;
  4.     struct message *next;
  5. }message;
  6. .....
  7. .....
  8. .....
  9. /* Get a node before a node */
  10. message *nodeBefore ( message *text ) {
  11.     message *tem;
  12.     tem = head;
  13.     /* If there are only 2 nodes ( a and b ),then nodeBeforeByText of a is returning to a */
  14. 184:if ( strcmp(tem->messageText,text) == 0)
  15.            return tem;
  16.        else {
  17.            while ( tem  != NULL ) {        
  18. 188:         if ( strcmp(tem->next->messageText,text) == 0 )            
  19.                     break;        
  20.              else
  21.                     tem = tem->next;
  22.           }
  23.        }
  24.        return tem;   
  25. }
  26.  
When I compiled there were messages :
Expand|Select|Wrap|Line Numbers
  1. q2.c:184: warning: passing arg 2 of `strcmp' from incompatible pointer type
  2. q2.c:188: warning: passing arg 2 of `strcmp' from incompatible pointer type
  3.  
After looking up the reference for strcmp() in library, I still dont understand why there are messages here.Can some body explain to me.
Mar 12 '08 #1
2 2078
Laharl
849 Recognized Expert Contributor
text is a message*, a pointer to a message (the struct type), not a string, a char*, which is what strcmp expects.
Mar 12 '08 #2
thungmail
9 New Member
text is a message*, a pointer to a message (the struct type), not a string, a char*, which is what strcmp expects.
Yeah Thanks. I got it now
Mar 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8981
by: Lian | last post by:
Hi all, I am confused by the rule of comparing two unicode string using function "strcmp". For exmaple, using "strcmp" to compare two Chinese uincode string, depending on what rule can "PHP" decide one string is greater or less than the other string? Thank you for suggestions!
7
5066
by: CoolPint | last post by:
While I was testing my understanding of Functioin Template features by playing with simple function templates, I got into a problem which I cannot understand. I would be very grateful if someone offered me a kind explanation. TIA Function template and specialization below works fine: template <typename T> T maximum (T a, T b) {
4
1244
by: Andrew | last post by:
Is it possible a constructor of a class to use a funtion defined in the same class ????
12
2025
by: Francis Bell | last post by:
Hello, I've got a program that is reading in a data file of 25 lines. Here is an example of the first two lines: sp/spinnerbait/AAA Lures/Mad Phil/silver/bass/1/1 f/floating minnow/AAA Lures/Skinny Minney/green/bass/0/0/0 In my program, I need to read in each line, BUT, I need to build a different object based upon the characters in...
11
11436
by: xuatla | last post by:
Hi, I want to compare two strings regardless of the lowercase or uppercase. For example, "txt" same as "TXT", "Txt", ... I know that there's stricmp in some c++ that can perform a lowercase comparison. But when I use <cstring>, I can't find such function. Do you know any other standard c++ function(s) can do this task? Thanks,
9
5248
by: Steven | last post by:
Hello, I have a question about strcmp(). I have four words, who need to be compared if it were two strings. I tried adding the comparison values like '(strcmp(w1, w2) + strcmp(w3, w4))', where w1 and w2 make up the first string and, w3 and w4 make up the second string. I do not want to allocate memory, then put the words together to create...
10
351
by: CodeBlaster | last post by:
Hi to all of you, I m new to C programming & i have a question *Generate a series such that after taking a number (e.g.99),when we press enter, the program should give an output which has no repeated digits & should contain no zeros (i.e after 99 123 is such a number).
6
1782
by: Bill Cunningham | last post by:
As I have been studing my tutorial I came up with this question. I took char passw(char name); and initialied this function in a header with other includes for standard library headers. This doesn't seem to work so is what I want this? char passw(char *name); I haven't got to pointers in the tutorial and I'm taking my time. But in this...
18
2610
by: mdh | last post by:
May I ask the following. By K&R's own admission, the example used to describe function pointers is complex ( on P119). In addition, the use of casts has been stated by some on this group as being, again, a poor/bad example of it's use. For the moment, accepting these criticisms, I would still like to get some insight into why/how some...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.