-
September 28th, 2013, 07:01 AM
#1
[RESOLVED] strcmp on Linked List data and string constants?
Was wondering why strcmp() doesn't return true when comparing a string constant with a string that was acquired via a linked list. By the way, the data in the linked list was taken from a text file. Does that imply that there's a new line (\n) character in the string from the linked list?
Code:
struct Node{
char ACNO[15];
struct Node *next;
} *start, *end;
static char acctNum[20];
... locateUser(acctNum); ...
void locateUser(const char* a){
// Locate user in the master file
struct Node *temp;
temp = start;
while(temp){
if(strcmp(a, temp->ACNO)){
printf("match");
}
temp = temp->next;
}
}
-
September 28th, 2013, 07:48 AM
#2
Re: strcmp on Linked List data and string constants?
sorry, it seems to be working just fine. strcmp() returns a 0 when both character arrays are the same.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|