Faulty programme!!!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2004
Posts: 16
Reputation: shouvik is an unknown quantity at this point 
Solved Threads: 0
shouvik's Avatar
shouvik shouvik is offline Offline
Newbie Poster

Faulty programme!!!

 
0
  #1
Sep 3rd, 2004
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;
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Faulty programme!!!

 
0
  #2
Sep 3rd, 2004
What's the error? And this looks like just a fragment of the program, as it has no main(). Maybe something else is needed?
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 24
Reputation: XianBin is an unknown quantity at this point 
Solved Threads: 0
XianBin XianBin is offline Offline
Newbie Poster

Re: Faulty programme!!!

 
0
  #3
Sep 5th, 2004
yes, a perfectly C program must have a main() function.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 16
Reputation: shouvik is an unknown quantity at this point 
Solved Threads: 0
shouvik's Avatar
shouvik shouvik is offline Offline
Newbie Poster

Re: Faulty programme!!!

 
0
  #4
Sep 5th, 2004
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???
:cool: !Life RULZ As LOng As iT's FuN!:o [/COLOR]
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 5
Reputation: Pietro is an unknown quantity at this point 
Solved Threads: 0
Pietro Pietro is offline Offline
Newbie Poster

Re: Faulty programme!!!

 
0
  #5
Sep 8th, 2004
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC