Thread: compiling hello world.c in vc++ 05 enterprise edition

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    3

    compiling hello world.c in vc++ 05 enterprise edition

    hi,

    How do I compile the following c program in vc++ and run it so that I can see the printf function.

    #include "stdafx.h"
    #include <stdio.h>
    #include <conio.h>

    void main(void)
    {
    printf("Hello world");

    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    1. don't use conio.h
    2. use int main
    3. read FAQ http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    Code:
    #include <stdio.h>
    int main(void)
    {
    	printf("Hello, world!\n");
    	getchar();
    	return 0;
    }
    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
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I doubt you will need the preciompiled header stdafx, so disable it by clicking on project options / C++ / precompiled headers / click "not using precompiled headers".

    Please note the above is rthe procedure using MSVC++2003 but it should work on all versions the same way
    Double Helix STL

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    3

    does not work

    Hi,
    Thanks for the help , but the screen does not print " hello world" and I get the message " Press any key".

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    What's your latest code?
    Do you see any error messages when compiling?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    3
    No error messages, I posted the code provided by vart, also does build
    creates an exe file , and where it is stored.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Are you sure you created a "win32 console" project?

    If you know where the executable is stored, then open a console window and type "CD \path" (where \path is where your executable is), then try running your executable from the command line (by typing in its name)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

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, 02:39 PM
  2. vc express compiling???
    By code2d in forum C++ Programming
    Replies: 1
    Last Post: 12-06-2006, 01:14 PM