• Register
1 vote
31 views

Problem:

I wrote the following subclass for my main program:

#include <stdio.h>
#include <stdlib.h>
#include "function.h"

#define READFILE "r"
#define WRITEFILE "w"
#define WORDARRAYSIZE 16
#define MAXIMUMWORDCHARACTERS 15

void CreateWordList (char inputFileName [ ])
{
   FILE* inputFile;
   
   inputFile = fopen (inputFileName, WRITEFILE);
   
   if (inputFile == NULL)
   {
      fprintf(stderr, "Error - Cannot open %s for reading!\n", 
	      inputFileName);
      
      exit (-1);
   }
}



int CountNumberOfWords (FILE* inputFile)
{
   int wordCounter = 0;
   char wordArray [WORDARRAYSIZE];
   
   while (fgets (wordArray, WORDARRAYSIZE, inputFile) != NULL )
   {
      wordCounter++;
   }
   
   return wordCounter;
}

Basically, I'm just trying to count the number of words in a data file, where you have no idea how many words are actually there. The first function has not been completed and is completely useless in its remedial stages, but somewhere, the following error occurs, “Undefined reference to main c++”

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution:

It seems like you are a pretty advance programmer, unfortunately, you did a basic level mistake in your code.

The main() function is the life of a c++ program and I didn’t find any main() in your program. Put the main()

int main()
{
  return 0;
}

 

 in your code on the proper section and give it another try. It should work fine for sure.
Thanks.

13 9 6
94,240 points

Related questions

0 votes
1 answer 17 views
17 views
Problem: Apart from the system and semantic errors and exceptions that occur from time to time, we also get other critical errors that affect the running of programs. These errors mostly occur towards the end of the program at runtime. Sometimes the program gives proper output and then the error occurs.
asked Dec 23, 2020 Mashhoodch 9.3k points
0 votes
1 answer 13 views
13 views
Problem: how to fix undefined reference to main c++
asked Feb 15 jasimchaudary 640 points
0 votes
1 answer 45 views
45 views
Problem I am getting an error that is undefined reference to a constructor. Program.cc #include "words.h" #include <string>   using namespace std;   int main(int argc, char* argv[]){   string file = "words.txt";   Words w1(file);     return 0; } Word ... then print it out. I know there is something missing in this code.so please provide me the correct solution of this will be appreciative for me
asked Dec 22, 2020 chris jordan 2.4k points
0 votes
1 answer 17 views
17 views
Problem: I have the following error in my Calculator code and do not understand how to correct it. Please any advice would be helpful. ERROR: error: jump to case label [-fpermissive]| error:crosses initialization of 'int sum'| error: 'exit' was not declared in this scope|
asked Dec 26, 2020 Mashhoodch 9.3k points
0 votes
1 answer 66 views
1 vote
1 answer 1.2K views
1.2K views
Problem: I am very new to Programming. I want to compile my recently written program it is called myes3 but when I try to write from the terminal: gcc myes3.c -o myes3 I always face below error message: /usr/lib/gcc/i686-linux-gnu/4.4.5/../../. ... collect2: ld returned 1 exit status I have very elementary knowledge of programming so unable to fix above error. Please help me in fixing above error.
asked May 27, 2020 Martin K 6.6k points
0 votes
2 answers 631 views
631 views
Problem : I am unable to figure out what is wrong with my code. When I try to compile my code I get the below message: &ldquo;Program does not contain a static 'main' method suitable for an entry point&rdquo;
asked Jan 29, 2020 jwilliam 3.9k points
0 votes
2 answers 409 views
409 views
Problem : I got bellow message from my code Exception in thread "main" java.lang.ArithmeticException: / by zero
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 621 views
621 views
Problem : In my code have main method in it. The program compiles on jgrasp with no errors but it keeps giving me a message as bellow: "no main methods, applets, or Midlets found in file jgrasp"
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 13 views
13 views
problem: I just started programming in C++, and I've attempted to create 2 classes where one will contain the other. Document A.h: #ifndef _A_h  #define _A_h  class A{  public:  A(int id);  private:  int _id;  B _b;/HERE I GET A COMPILATION ERROR: B does not name a type  } ... then the A class, yet then I get the blunder message: A.h:9: error: 'B' does not name a type  How would I fix this issue?
asked Feb 17 kaash_kashi 1.2k points