Thread: I'm new and could use some help

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    5

    I'm new and could use some help

    Hi I'm new to this board and C++ programing and, I need some help. I am creating a simple program that should produce Hello, world! as text in a MS DOS screen
    Code:
    /*Hello world program
      Zeratul_999, 12/5/02*/
    
    #include<iostream.h>
    
    int main()
    {
    	cout << "Hello, world!";	//first statement
    	return(0);	//second statement	
    }
    This is what I get in the build log


    Build Log

    --------------------Configuration: Hello world program - Win32 Debug--------------------

    Command Lines
    Creating temporary file "C:\WINDOWS\TEMP\RSP7301.TMP" with contents
    [
    /nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/Hello world program.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
    "C:\My Documents\C++\Chapter 2\Hello world program.cpp"
    ]
    Creating command line "cl.exe @C:\WINDOWS\TEMP\RSP7301.TMP"
    Output Window
    Compiling...
    Hello world program.cpp
    c:\my documents\c++\chapter 2\hello world program.cpp(11) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.



    Results
    Hello world program.obj - 1 error(s), 0 warning(s)

  2. #2
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    That's odd. What compiler are you running?

  3. #3
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    correct code/works, what compiler are you using? Try <iostream> minus the ".h"

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    #include "stdafx.h" at the very top. Either that or create a project without precompiled headers... or remove precompiled headers from your project options.

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    5
    Code:
    /*Hello world program
      Dennis McCollum, 12/5/02*/
    
    #include<iostream>
    
    int main()
    {
    	cout << "Hello, world!";	//first statement
    	return(0);	//second statement
    }
    This also didn't work

    #include "stdafx.h" at the very top. Either that or create a project without precompiled headers... or remove precompiled headers from your project options.
    stdafx.h doesnt work.
    Precompiled headers, I unfortinatly do not know what theese are explain?
    I dont know what compiler I'm using. I'm doing this at school with Visual C++ 6, maybe I should reinstall it?

  6. #6
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    when you create your project make sure you do Win32 console application and then select empty project from the next set of options. you probably didn't set up your project properly the first time. recreate it and use these settings

  7. #7
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    When you #include it make sure you use double quotes "" and not brackets <>. I'm not exactly sure how to disable these from an existing project.. but you can easily create a new project and select "empty project"

  8. #8
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Ahh, here it is.
    -Project -> Settings ->
    -Select the C/C++ tab on the left
    -Select "Precompiled Headers" from the combo box
    -Select "Not using precompiled headers"
    Last edited by Eibro; 12-05-2002 at 08:09 PM.

  9. #9
    Registered User
    Join Date
    Dec 2002
    Posts
    5
    LOL I feel stupid I chose Win32 console application but i did not choose empty program

    and what is the benifet of using double qoutes instead of brackets
    I checked the cprograming tutorials and it also has it in brackets http://www.cprogramming.com/tutorial/lesson1.html
    Last edited by Zeratul_999; 12-05-2002 at 08:32 PM.

  10. #10
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    you use quotes when the file you are trying to include is in your project directory (IE one you create), and arrow brackets when they are from another location -- like any standard headers

  11. #11
    Registered User
    Join Date
    Dec 2002
    Posts
    5
    Does the file automaticly go into my project file if i use double qoutes?

  12. #12
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    no, if you want to include iostream for instance, use arrow brackets. if you don't your program won't compile, unless, of course, you copy iostream into your project (which would be pointless) or if you made a header of your own and called it iostream

  13. #13
    Registered User
    Join Date
    Dec 2002
    Posts
    5

    Thumbs up

    Ok thanks alot.

  14. #14
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    From MSDN:
    Syntax Form/Action

    Quoted form:
    This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of whatever files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.

    Angle-bracket form:
    This form instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then along the path specified by the INCLUDE environment variable.
    Last edited by Hunter2; 12-05-2002 at 10:52 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed