943,341 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2829
  • C++ RSS
Sep 3rd, 2004
0

Faulty programme!!!

Expand Post »
help. this programme shows linking error!!! :cry: :cry: :cry:

#include "diction.h"

int Dictionary::find_word(char *s)
{
char word[81];
for (int i = 0; i < nwords; ++i)
if (stricmp(words[i].get_word(word),s) == 0)
return i;

return -1;
}

void Dictionary::add_def(char *word, char **def)
{
if (nwords < Maxwords)
{
words[nwords].put_word(word);
while (*def != 0)
words[nwords].add_meaning(*def++);
++nwords;
}
}

int Dictionary::get_def(char *word, char **def)
{
char meaning[81];
int nw = 0;
int word_idx = find_word(word);
if (word_idx >= 0)
{
while (words[word_idx].get_meaning(nw,meaning) != 0)
{
def[nw] = new char[strlen(meaning)+1];
strcpy(def[nw++],meaning);
}
def[nw] = 0;
}

return nw;
}
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
shouvik is offline Offline
16 posts
since Aug 2004
Sep 3rd, 2004
0

Re: Faulty programme!!!

What's the error? And this looks like just a fragment of the program, as it has no main(). Maybe something else is needed?
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
Sep 5th, 2004
0

Re: Faulty programme!!!

yes, a perfectly C program must have a main() function.
Reputation Points: 15
Solved Threads: 0
Newbie Poster
XianBin is offline Offline
24 posts
since Aug 2004
Sep 5th, 2004
0

Re: Faulty programme!!!

Quote originally posted by XianBin ...
yes, a perfectly C program must have a main() function.
Yeah but how do i write the main. I just dont seem to get it???
Reputation Points: 11
Solved Threads: 0
Newbie Poster
shouvik is offline Offline
16 posts
since Aug 2004
Sep 8th, 2004
0

Re: Faulty programme!!!

Quote originally posted by shouvik ...
help. this programme shows linking error!!! :cry: :cry: :cry:

#include "diction.h"

int Dictionary::find_word(char *s)
{
char word[81];
for (int i = 0; i < nwords; ++i)
if (stricmp(words[i].get_word(word),s) == 0)
return i;

return -1;
}

void Dictionary::add_def(char *word, char **def)
{
if (nwords < Maxwords)
{
words[nwords].put_word(word);
while (*def != 0)
words[nwords].add_meaning(*def++);
++nwords;
}
}

int Dictionary::get_def(char *word, char **def)
{
char meaning[81];
int nw = 0;
int word_idx = find_word(word);
if (word_idx >= 0)
{
while (words[word_idx].get_meaning(nw,meaning) != 0)
{
def[nw] = new char[strlen(meaning)+1];
strcpy(def[nw++],meaning);
}
def[nw] = 0;
}

return nw;
}


I am a first year student in c++ but maybe have you tried the create a Header file first with the following

#ifndef diction.h
#define diction.h

your Header file declarations
then add at the end

#endif
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pietro is offline Offline
5 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: A question about 'const'
Next Thread in C++ Forum Timeline: Delete words error!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC