expected constructor, destructor, or type conversion before '('

This is a discussion on expected constructor, destructor, or type conversion before '(' within the C Programming forums, part of the General Programming Boards category; I keep on getting an error "expected constructor, destructor, or type conversion before '(' token expected `,' or `;' before ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    13

    expected constructor, destructor, or type conversion before '('

    I keep on getting an error "expected constructor, destructor, or type conversion before '(' token expected `,' or `;' before '(' token " I cannot seem to get passed this, any help with this would be greatly appreciated.

    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    #include <conio.h>
    #include<stdlib.h>
    
    
    using namespace std; 
    
    
    //
    // Structure to hold a letter and the number of times it has occurred
    //
    
    const int MAX_LETTERS = 26 ;
    
    struct letterCount
    {
      char letter;
      int count;
      int count_caps;	// number of capital occurrences
    
    };
    
    
    
    
    int static	openFile (FILE*& in ,FILE*& ot) ;
    
    void static count (letterCount* a, FILE*& fin, int& td, int& w_num, unsigned int& line) ;
    void static printResult (letterCount a[], FILE*& out, int total_digits, int w_num, unsigned int& line) ;
    
    int main()
    {
    	letterCount counts[MAX_LETTERS];
    	int total_digits ;
    	int w_num ;
    	unsigned int line;
    
    	FILE* in;
    	FILE* out;
    
    	memset (counts, 0x00, sizeof(counts)) ;
    
    	if ( 0 > (openFile (in , out))) 
    	{
    		getch() ;
    		return -1 ;
    	}
    
    	total_digits = 0 ;
    	w_num = 0; 
    	line = 0 ;
    	count (counts, in, total_digits, w_num, line) ;
    
    	printResult (counts, out, total_digits, w_num, line) ;
    
    	getch() ;
    
    	return 0 ;
    }
    
    
    
    printf("The Input file has %d words\n", w_num);
    	fprintf(out, "\nThe Input file has %d words\n", w_num);
    
    	printf("The Input file has %d lines\n", line);
    	fprintf(out, "\nThe Input file has %d lines\n", line);
    
    
    
    
    void static count (letterCount* a, FILE*& fin, int& td, int& w_num, unsigned int& line) 
    {
    	char ch, ch1;
    	unsigned int i=0, minLine=0, minChars=65535, maxLine=0, maxChars=0, totChars=0;
    	int w_state ;								// 0 - not-word; 1-word;
    	line = 0 ;
    	td = 0 ;									// total number of digits
    
    	w_num = 0 ;
    	w_state = 0 ;								// idle, looking for word start
    	i = 0;
    	ch = fgetc(fin);
    	while (ch != EOF){							/* Read until EOF is reached */
    
    		if (isalnum (ch)) 
    		{
    			if (0 == w_state) 
    			{
    				w_state = 1 ; // started word
    			}
    		}
    		else 
    		{
    			if (1 == w_state)
    			{
    				w_state = 0 ;					// idle, looking for word start			
    				w_num++ ; 	
    			}
    		}
    
    
    		if (isalpha (ch)) 
    		{
    			int up = isupper (ch) ? 1 : 0 ;
    			ch1 = ch ;
    			int idx = tolower(ch1) - 'a' ;
    			a [idx].count++ ;
    			a [idx].letter = ch1 ;
    			a [idx].count_caps += up ;
    		}
    		else 
    		{
    			if (isdigit (ch)) 
    			{
    				td++ ;
    			}
    		}
    
    		i++;									/* Count the characters*/
    		ch = fgetc(fin);
    		if ( ch=='\n'){
    			line++;								/* increment when a newline is found*/
    			totChars += i-1;					/* Correction for \n (newline) character*/
    
    			if (i<minChars){
    				minChars = i;
    				minLine = line;
    			}
    			else if (i>maxChars || minChars>maxChars){
    				maxChars = i;
    				maxLine = line;
    			}
    
    			i = 0;
    		}
    
    	}
    
    	if (i > 0) // last line may not have \n (newline) character
    	{
    		line++; /* increment when a newline is found*/
    		totChars += i; /* Note, no \n (newline) character*/
    		
    		if (1 == w_state) 
    			w_num++ 
    		;
    
    		if (i<minChars){
    			minChars = i;
    			minLine = line;
    		}
    		else if (i>maxChars || minChars>maxChars){
    			maxChars = i;
    			maxLine = line;
    		}
    
    		i = 0;
    	}
    
    	/* The file has been read */
    	// printf("\nThe Input file has %d lines\n", line);
    
    
    
    int static	openFile (FILE*& in ,FILE*& out) 
    {
    	char name [256];
    
    	cout << "Enter input file name:" << endl ;
    	cin.getline(name, 255);
    
    	in = fopen(name,"r");
    	
    	if (!in) 
    	{	// printf ("File \"input.txt\" was not opened!\n") ;
    		cout << "File " << name << " was not found!" << endl ;
    		return -1 ;
    	}
    
    	cout << "Enter output file name:" << endl ;
    	cin.getline(name, 255);
    
    	out = fopen(name,"w");
    	
    	if (!out) 
    	{	
    		cout << "File " << name << " could not be created!" << endl ;
    		return -1 ;
    	}
    
    }

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Make up your mind if this is C or C++.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    A line number would be nice, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    13
    Lines 65, 66, 68, 69

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    You have code that is placed outside a function. That is illegal. It must be within a function.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    Make up your mind if this is C or C++.
    Quoted for truth.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 10:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Windows using Dev-C++
    By Renegade in forum C++ Programming
    Replies: 15
    Last Post: 07-07-2005, 09:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21