Thread: First try to Hello World , failed!

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    69

    First try to Hello World , failed!

    Well I was trying to make a hello world thing and well i dont know what went wrong please help me eres the log

    Building resource file...
    Compiling files :
    C:\DEV-C_~1\BIN\g++ "c:\my documents\untitled1.cpp" -c -s -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G__~1 -IC:\DEV-C_~1\INCLUDE\ -LC:\DEV-C_~1\LIB\ -BC:\DEV-C_~1\BIN\
    Linking files :
    C:\DEV-C_~1\BIN\g++ "c:\my documents\untitled1.o" -o c:\mydocu~1\Projec~1.exe C:\MYDOCU~1\RSRC.o -s -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G__~1 -IC:\DEV-C_~1\INCLUDE\ -LC:\DEV-C_~1\LIB\ -BC:\DEV-C_~1\BIN\


    thanks.

  2. #2
    unknown
    Guest
    Source Code?

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    69
    The source code is

    #include <iostream>
    #include <conio.h>

    int main()
    {
    cout << "Hello World\n";
    getch();
    }

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    after the includes put in a using namespace std;
    i dont know if this will help or not, but thats what u should do anyway
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    include whatever the header file is for getch()

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    getch() is in conio.h
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  7. #7
    Registered User
    Join Date
    Jun 2002
    Posts
    13
    I use gcc, and it outputs to a.exe if you don't specify an output name. I don't know how your compiler does it, but it may have generated a default executable. check your directory.

    also, while namespace is customary and good programming practice,
    Code:
    using namespace std;
    doesn't really do anything (it defaults to std namespace). It won't fix any compile errors.

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    99

    hmm

    Try putting a 'return 0;' before the closing bracket, I'm not sure if this will help though... We're there even any errors?

  9. #9
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    You have your main() function of type int, yet it doesn't return anything? Do what Da-Spit said and change your code to
    Code:
    #include <iostream> 
    #include <conio.h> 
    
    int main() 
    { 
    cout << "Hello World\n"; 
    getch(); 
    
    return 0;
    }

  10. #10
    Registered User
    Join Date
    Sep 2001
    Location
    England
    Posts
    121
    I'm an old school programmer, and I dont normally use namespace std; through habit, but I always use #include<iostream.h> rather than #include<iostream>, I've seen <iostream> where using namespace std; is used but never without, so maybe that's the problem. I don't have a compiler here though so I cant check it. Looking back at the compiler output though it seems to get to the linking stage, so I dont think this will have anything to do with it.

  11. #11
    Registered User
    Join Date
    Jun 2002
    Posts
    69
    thanks for your help all I changed compliars to microsoft's visual C++ Standered and I put the source code and compiled and ran and it executed a black screen that said hello world please press enter to continue is that write?

  12. #12
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    yes, congratulations!! You are now a C++ programmer

  13. #13
    Registered User
    Join Date
    Jun 2002
    Posts
    69
    YAY HAHA watch out you other programmers im moving write along to kick yo A$$'$

  14. #14
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    Yes I'm definitely frightened

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  2. The 7 New Wonders of the World
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 12-08-2006, 01:55 PM
  3. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM