the function first search a word from the linked list. if found it then increment the numWords (number of words in listfor that word) and if not found it shoud create a new node for the word.
the code is: - void AddWords( char text[30])
-
{
-
-
check=head;
-
-
while (check!=NULL)
-
{
-
if (strcmp(check->words,text[30])==0)
-
{
-
check->numWords++;
-
break;
-
}
-
else
-
{
-
newNode=getmem();
-
strncpy(newNode->words,text, 29);
-
newNode->next=head;
-
head=newNode;
-
}
-
check=check->next;
-
-
}
i am having this compiler error:
Warning] passing arg 2 of `strcmp' makes pointer from integer without a cast
for this line of code: - if (strcmp(check->words,text[30])==0)
8 1368
the function first search a word from the linked list. if found it then increment the numWords (number of words in listfor that word) and if not found it shoud create a new node for the word.
the code is: - void AddWords( char text[30])
-
{
-
-
check=head;
-
-
while (check!=NULL)
-
{
-
if (strcmp(check->words,text[30])==0)
-
{
-
check->numWords++;
-
break;
-
}
-
else
-
{
-
newNode=getmem();
-
strncpy(newNode->words,text, 29);
-
newNode->next=head;
-
head=newNode;
-
}
-
check=check->next;
-
-
}
i am having this compiler error:
Warning] passing arg 2 of `strcmp' makes pointer from integer without a cast
for this line of code: - if (strcmp(check->words,text[30])==0)
Try this:
if (strcmp(check->words,text)==0)
Two arguments to strcmp shd. be adresses always..
Array name is equal to its address so pass text only..
arne 315
Expert 100+
Warning] passing arg 2 of `strcmp' makes pointer from integer without a cast
for this line of code: - if (strcmp(check->words,text[30])==0)
It's a warning, not an error. The compiler warns you that strcmp expected another type for its 2nd argument, namely 'const char *', but you passed an int. So the compiler will translate it, but it may not what you wanted ...
BTW, why did you start a new thread? Didn't we discuss this yesterday? What was wrong with thread http://www.thescripts.com/forum/thread552877.html ??
i tried that but when debugging i am having this error
An Access violation(segment fault) raised in your program.
the line of code crushinhg the program is: - if (strcmp(check->words,temp)==0)
arne 315
Expert 100+
i tried that but when debugging i am having this error
An Access violation(segment fault) raised in your program.
the line of code crushinhg the program is: - if (strcmp(check->words,temp)==0)
In my program? IIRC, I haven't sent you any program :)
arne 315
Expert 100+
In my program? IIRC, I haven't sent you any program :)
Oops, these were the compiler's word spoken to you, not your words spoken to me ... got it.
Oops, these were the compiler's word spoken to you, not your words spoken to me ... got it.
in just dont get it . what are u trying to say
Try this:
if (strcmp(check->words,text)==0)
Two arguments to strcmp shd. be adresses always..
Array name is equal to its address so pass text only..
i tried that but when debugging i am having this error
An Access violation(segment fault) raised in your program.
the line of code crushinhg the program is: - if (strcmp(check->words,temp)==0)
arne 315
Expert 100+
i tried that but when debugging i am having this error
An Access violation(segment fault) raised in your program.
the line of code crushinhg the program is: - if (strcmp(check->words,temp)==0)
It should be 'text', not 'temp', I think.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: C++fan |
last post by:
Suppose that I define the following class:
class example_class{
public:
example_class();
void funtion_1();
void function_2();
protected:
|
by: Dream Catcher |
last post by:
1. I don't know once the node is located, how to return that node.
Should I return pointer to that node or should I return the struct of that
node.
2. Also how to do the fn call in main for that...
|
by: Kent |
last post by:
Hi!
I want to store data (of enemys in a game) as a linked list, each node will
look something like the following:
struct node
{
double x,y; // x and y position coordinates
struct enemy...
|
by: Steve Lambert |
last post by:
Hi,
I've knocked up a number of small routines to create and manipulate a linked
list of any structure. If anyone could take a look at this code and give me
their opinion and details of any...
|
by: dssuresh6 |
last post by:
Whether browsing forward or backward can be done using a singly linked
list. Is there any specific case where a doubly linked list is needed?
For people who say that singly linked list allows...
|
by: XXXXXX.working.in.my.blood |
last post by:
hi all,
i need help with linked lists...
the problem is this, "reverse the contents of a singly linked list
without using a temporary node"...
solution with code will be appreciated...
|
by: Y2J |
last post by:
I am working through this book on C++ programming, the author is
speaking of using linked lists. He gave and example which I found
confusing to say the least. So I rewrote the example in a way that...
|
by: joshd |
last post by:
Hello,
Im sorry if this question has been asked before, but I did search
before posting and couldnt find an answer to my problem. I have two
classes each with corresponding linked lists, list1...
|
by: Joerg Schoen |
last post by:
Hi folks!
Everyone knows how to sort arrays (e. g. quicksort, heapsort etc.)
For linked lists, mergesort is the typical choice.
While I was looking for a optimized implementation of mergesort...
|
by: Atos |
last post by:
SINGLE-LINKED LIST
Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |