Haven't use C++ in a while, but this should be easy...>.>;

This is a discussion on Haven't use C++ in a while, but this should be easy...>.>; within the C++ Programming forums, part of the General Programming Boards category; I have to write a program that outputs multiple-choice questions, takes the user's choices, then gives them a score. I ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    1

    Question Haven't use C++ in a while, but this should be easy...>.>;

    I have to write a program that outputs multiple-choice questions, takes the user's choices, then gives them a score.

    I get an error message everytime I try to cout<< a string, however. Instead of posting my long code for the project, here is some simple code getting the same problem.

    Code:
    #include <iostream>
    
    using namespace std;
    
    void main () {
    	
    	string s = "Hi!";
    	cout<<s;
    
    }
    Now...what am I missing? It's been two years since I've had to code C++, so its likely something i'm failing to include, but my google searched have turned up nothing except #include <string>, which failed to solve the problem.

    Here is the error message:

    1>------ Build started: Project: Become a Millionaire, Configuration: Debug Win32 ------
    1>Compiling...
    1>tryme.cpp
    1>.\tryme.cpp(2) : fatal error C1083: Cannot open include file: 'stream': No such file or directory
    1>Build log was saved at "file://c:\Documents and Settings\Michael\My Documents\CyberCamps\C++ Programs\millionaire\Become a Millionaire\Debug\BuildLog.htm"
    1>Become a Millionaire - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Version info here:
    "Microsoft Visual Studio 2005
    Version 8.0.50727.42 (RTM.050727-4200)
    Microsoft .NET Framework
    Version 2.0.50727

    Installed Edition: VC Express

    Another potential problem is I just finished a semester of Java programming. Suddenly, I don't remember if you can even output strings in C++. I'd imagine you could...*scratches his head*
    Last edited by vyen; 06-02-2007 at 01:17 PM.

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    hmmm...it's probably not a good thing that it can't open up "stream", as it is an essential C++ header file. that is kind of baffling. Check the MSVC++ include directory to make sure stream is there...if it's not, I bet you can find it on the internet (although you would have to make sure it is the correct version of "stream"...who knows what MSVC++ uses).

    Other than that, yes, make sure to include "string" in order to use strings, and make sure you are using "int main" and not "void main" (then return 0 at the end of main)...it's the standard.
    My Website

    "Circular logic is good because it is."

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    more likely, your build environment doesn't know where your include directory is. Check your build settings in your IDE and/or the environment settings.
    Last edited by robwhit; 06-02-2007 at 02:41 PM.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Yes the include directory would probably be off, however once you do get the correct include directory you will need to have this line:
    #include <string> (It should work when you have the right directory)

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    Did you download the platform SDK?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Easy String position question...
    By Striph in forum C Programming
    Replies: 4
    Last Post: 05-11-2009, 08:48 PM
  2. Seg fault in easy, easy code
    By lisa1901 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2007, 04:28 AM
  3. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  4. Replies: 20
    Last Post: 05-25-2002, 07:14 PM

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