Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ undefined reference to defined function
    primarykey
    data
    text
    <p>I cannot figure out why this is not working. I will put up all three of my files and possibly someone can tell me why it is throwing this error. I am using g++ to compile the program.</p> <p>Program:</p> <pre><code>#include &lt;iostream&gt; #include "h8.h" using namespace std; int main() { char sentence[MAX_SENTENCE_LENGTH]; char writeTo[] = "output.txt"; int distanceTo,likePosition, length, numWords; cout &lt;&lt; "ENTER A SENTENCE! "; cin.getline(sentence, 299); length = strlen(sentence); numWords = wordCount(sentence, length); for(int x = 0; x &lt; 3; ++x) { likePosition = likePos(numWords); distanceTo = lengthTo(sentence, likePosition, length); insertLike(sentence, distanceTo, length, writeTo); } return 0; } </code></pre> <p>Function file:</p> <pre><code>void insertLike(const char sentence[], const int lengthTo, const int length, char writeTo[]) { char part1[MAX_SENTENCE_LENGTH], part2[MAX_SENTENCE_LENGTH]; char like[] = " like "; for(int y = 0; y &lt; lengthTo; ++y) part1[y] = sentence[y]; for(int z = lengthTo+1; z &lt; length - lengthTo; ++z) part2[z] = sentence[z]; strcat(part1, like); strcat(part1, part2); writeToFile(sentence, writeTo); return; } </code></pre> <p>Header file:</p> <pre><code>void insertLike(const char sentence[], const int lengthTo, const int length, const char writeTo[]); </code></pre> <p>The error exactly is:</p> <pre><code>undefined reference to 'insertLike(char const*, int, int, char const*)' collect2: ld returned 1 exit status </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload