Thread: cannot run win32 console program in vc++ standard

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile cannot run win32 console program in vc++ standard

    Hey all,
    I am new in VC++.. I have been trying to follow the book that I am reading and it tells me to compile the program HelloWorld2 using Win 32 Console (I am using VS 2005 Standard). I followed the setting that the book said and tried to build it in the manner the book instructed, debugging it in the command prompt. I did and it said:

    Code:
    "The system cannot find the path specified."
    I don't know what that meant since I tried to run it from the right directory based on the book's instructions.
    I also tried to run it from the VC++ editor but it gave me this error:

    Code:
    fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
    By the way, here is the code:

    Code:
    // HelloWorld2
    // Prints hello world on the screen
    // Unmanaged
    
    #include "stdafx.h"
    #include <iostream.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	//Write to the screen
    	cout << "Hello World\n";
    	return 0;
    }
    Any inputs?
    Thanks..

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    1. Better to disable precompiled headers. It will be easier without them (look in the project settings)
    2. remove the stdafx.h include
    3. #include <iostream> should be - your book is outdated - use newer book
    4. std::cout or some using directive is required - code is outdated
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Question

    I did what you said and this was the output:

    Code:
    HelloWorld2 - 0 error(s), 0 warning(s)
    ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
    But when I debugged it at the command prompt, nothing happened.. no message, no warning, no error....

    For some reason, it said in the editor window that the file I was working on was a read only file. I didn't set it like that. Does that have anything to do with it?

    Here is the code:

    Code:
    // HelloWorld2
    // Prints hello world on the screen
    // Unmanaged
    
    #include <iostream>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	//Write to the screen
        std:cout << "Hello World\n";
    	return 0;
    }
    Thanks..

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DEV-C++ made program crashes when run from outside the ide
    By rainmanddw in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2006, 10:27 PM
  2. Using C++ to run a Console APP?
    By anon2222 in forum C++ Programming
    Replies: 4
    Last Post: 01-10-2006, 08:07 AM
  3. Win32 console, xp,nt,2000 only?
    By Ash1981 in forum C Programming
    Replies: 8
    Last Post: 01-01-2006, 03:09 AM
  4. How To Convert A Dos-Prompt C++ PRogram Into Win32 Application ?
    By SonicWave in forum Windows Programming
    Replies: 1
    Last Post: 09-15-2001, 11:03 AM