Like Tree1Likes
  • 1 Post By rags_to_riches

[Linker error] undefined reference to `WinMain@16'

This is a discussion on [Linker error] undefined reference to `WinMain@16' within the C++ Programming forums, part of the General Programming Boards category; I tried writing following code but it says '' [Linker error] undefined reference to `WinMain@16' What should I do?? Code: ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    7

    [Linker error] undefined reference to `WinMain@16'

    I tried writing following code but it says ''
    [Linker error] undefined reference to `WinMain@16'

    What should I do??
    Code:
    #include<iostream>
    #include<fstream>
    using namespace std;
    
    int main()
    {
        
    int count;
    char word[30];
    char story[20]; 
    }
    void countword();
    
    
        
        ifstream fin;
        fin.open("STORY.TXT");
        char word[30];
        int count=0;
        while(!fin.eof())
        {
            fin>>word;
            if(strcmpi(word,"the")==0)
                count++;
        }
        cout<<"Number of the word in file are "<<count;
        fin.close();
        system("pause");
    
    }

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    You created the project as a Windows project instead of a console project. Re-create it as a console project. Or, if using Visual Studio, right-click on the project, choose Properties, go to Linker then System, and set the Subsystem configuration option to Console.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    If countword is supposed to be a function, then there should be no semicolon after the line.
    Also, you need to stop using char arrays. Use std::string.
    There is no need to manually close a stream. Just let it go out of scope.
    system is evil, don't use it. Learn how to pause the console in other ways.
    And just while we're at it, you probably don't know so, there are C++ arrays as well as C arrays. C++ arrays are known as std::array. Look it up!
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    There's more than that wrong with the code. Probably because he didn't go to class and is likely just copying and pasting code.
    Salem likes this.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    Uh-oh. Let's blacklist cppforschool.com.
    Clearly it is using C mixed in with C++ code and is prone for buffer overruns, too. Who knows what other kinds of crap is there?
    OP: Get a beginner's book such as C++ Primer (and read it!) and stop visiting cppforschool.com.
    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
    Registered User
    Join Date
    Oct 2011
    Posts
    7
    Can u plzz correct it for me???

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    No, do it yourself. Otherwise you will not learn.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker Error - Undefined Reference
    By DaNxTh3xMaNx in forum C Programming
    Replies: 3
    Last Post: 09-07-2011, 05:49 PM
  2. Linker Error/Undefined Reference
    By liljp617 in forum C Programming
    Replies: 2
    Last Post: 09-24-2008, 09:02 PM
  3. [Linker error] undefined ref to winmain@16 HELP!!!
    By mramazing in forum C++ Programming
    Replies: 12
    Last Post: 05-03-2008, 10:06 PM
  4. linker error undefined reference to
    By BJtoVisualcC++ in forum C++ Programming
    Replies: 3
    Last Post: 06-18-2007, 11:40 AM
  5. Linker Error (undefined reference)
    By Dae in forum C++ Programming
    Replies: 5
    Last Post: 07-15-2005, 03:50 PM

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