Thread: Weird Error. Please Help.

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    28

    Weird Error. Please Help.

    Well basically I am supposed to create a program that reads a specific file and counts the words,lines, and paragraphs (Paragraphs are considered to be anything with a full line of blank space inbetween text).


    When I run build in Visual C++ it seems as if it compiles just fine, but it won't link.

    I get the following error:

    error LNK2001: unresolved external symbol "void __cdecl processBlanks(class std::basic_ifstream<char,struct std::char_traits<char> > &,char &,int &)" (?processBlanks@@YAXAAV?$basic_ifstream@DU?$char_t raits@D@std@@@std@@A
    ADAAH@Z)

    fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.



    Now let me just say that, When I remove the functions from the program it works fine. So my guess is that it has something to do with how I am passing the ifstream to my functions.



    Code:
    #include <iostream>
    #include <fstream>
    
    
    using namespace std;
    
    
    void processBlanks(ifstream& Istream,char & ch, int & wordCount);
    void copyText(ifstream& Istream,char & ch);
    void updateCount(int & totalwordCount, int & wordCount, int & lines, int & paraGraph);
    void printTotal(int & totalwordCount, int & lines, int & paraGraph);
    
    
    
    
    //==============================================================================================================================================
    //========================================================== Main Function =====================================================================
    //==============================================================================================================================================
    
    
    int main()								// begin main function
    {
    
    ifstream Istream;
    ofstream Ostream;					   // Change name of Ofstream into Ostream
    
    
    int lines =0;
    int wordCount =0;
    int totalwordCount =0;
    int paraGraph = 0;
    char ch;
    
    												// Declaring variables as strings
    
    
    Istream.open("Yo.txt");								// Opening of the Text document
    Ostream.open("word.txt");
    
    Istream.get(ch);
    
     while (Istream != 0)	// Process the file (While 1)
     {
    
       while (ch != '\n')	 // Process the line (While 2)
        {
    	  processBlanks(Istream,ch,wordCount);
    	  copyText(Istream,ch);
    	}										// EoWhile 2
    
       updateCount(totalwordCount,wordCount,lines,paraGraph);
       cout << ch;
       Istream.get(ch);
    
    
    
     }											// EoWhile 1
    
    printTotal(totalwordCount,lines,paraGraph);
    
    Istream.close();
    Ostream.close();
    
     return 0;
    }
    //==============================================================================================================================================
    //======================================================= End of Function ======================================================================
    //==============================================================================================================================================
    
    
    
    
    
    
    //==============================================================================================================================================
    //========================================================== processBlank Function =============================================================
    //==============================================================================================================================================
    void processBlanks(ifstream& Istream,char & ch, int wordCount)
    {
    	 
    	while (ch == ' ')		// (While 3)
    	  {
    	   cout << ch ;
    	   Istream.get(ch);
       	  }
    
    	   if (ch != ' ' && ch != '\n')
    	   {
    		wordCount++;
    	   }
    
    
      return;
    }
    
    //==============================================================================================================================================
    //======================================================= End of Function ======================================================================
    //==============================================================================================================================================
    
    
    
    //==============================================================================================================================================
    //========================================================== copyText Function =================================================================
    //==============================================================================================================================================
    void copyText(ifstream& Istream,char & ch)
    {
    
    	 while (ch != ' ' && ch != '\n')			// While 4
    	 {
          cout << ch;
          Istream.get(ch);
    	 }
    
    
     return;
    }
    //==============================================================================================================================================
    //======================================================= End of Function ======================================================================
    //==============================================================================================================================================
    
    
    //==============================================================================================================================================
    //========================================================== updateCount Function ==============================================================
    //==============================================================================================================================================
    void updateCount(int & totalwordCount, int & wordCount, int & lines, int & paraGraph)
    {
     totalwordCount = totalwordCount + wordCount;
     lines++;
    
    	if (wordCount == 0)
    		{
    		 paraGraph++;
    		 lines--;
    		}
    
      wordCount = 0;
    
     return;
    }
    //==============================================================================================================================================
    //======================================================= End of Function ======================================================================
    //==============================================================================================================================================
    
    
    //==============================================================================================================================================
    //========================================================== printTotal Function ===============================================================
    //==============================================================================================================================================
    void printTotal(int & totalwordCount, int & lines, int & paraGraph)
    {
    	cout << "Total Words is equal to " << totalwordCount << endl;
    	cout << "Total Lines is equal to " << lines << endl;
    	cout << "Total paragraphs is equal to " << paraGraph << endl;
    
      return;
    }
    //==============================================================================================================================================
    //======================================================= End of Function ======================================================================
    //==============================================================================================================================================

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    void processBlanks(ifstream& Istream,char & ch, int & wordCount);
    void processBlanks(ifstream& Istream,char & ch, int wordCount) { ... }
    No match!

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    28
    Haha... It has been a long day.


    Thanks a lot for the help .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM