cout undeclared/cin undeclared

This is a discussion on cout undeclared/cin undeclared within the C++ Programming forums, part of the General Programming Boards category; i'm new to programming and am using djgpp i'm trying to build the common 1st program hello world... i've checked ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    4

    cout undeclared/cin undeclared

    i'm new to programming and am using djgpp i'm trying to build the common 1st program hello world... i've checked the forums for this problem i'm having and adjusted my code accordingly and am still getting the same error message:

    error: 'cout' undeclared (first use this function)
    error: (each undeclared identifier is reported only once for each function it appears in.)
    error: 'cin' undecalred (first use this function)

    heres my code:

    Code:
     
    #include <stdio.h>
    
    int main()
    {
      cout<<"HEY, you, I'm alive! Oh, and hello world!\n";
      cin.get();
    
      return 0;
    }

    i've replaced iostream with stdio.h because thats what they use on the djgpp website and after looking in my include folder i have no iostream file... makes sense to me... also i've removed the using namespace std; line becuase when i have that in there i get a whole slew of undefined reference to 'std messages... are these just compiler warnings and can/should i be removing the using namespace line like that or am i doing something stupid? hopefully i've included enough information to get help on my problem sorry for the probably simple question and i appreciate any help i can receive.

    on another note anyone else see the sabers/flyers game? that hit on umberger? wow good night gracy.
    Last edited by akbigchillin; 04-22-2006 at 09:44 PM.

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    4

    odd

    found something kind of odd to me maybe its because the code i typed was wrong somehow but i used this code i found on this board... still using stdio.h instead of iostream


    Code:
    #include <stdio.h>
    
    using namespace std;
    
    int main()
    {
      cout << "hello, world!"  << endl;
    
      cout << "press enter to continue..." << endl;
      cin.get();
    
      return 0;
    }

    what i find odd is i included the using namespace std; line and didn't get all the undefined reference to 'std messages... i still get the cout/cin undeclared messages along with endl undeclared (first use this function)...

  3. #3
    uninteresting
    Join Date
    Jun 2002
    Posts
    66
    <stdio.h> is the standard C I/O header. You're using C++. So go ahead and replace the <stdio.h> with <iostream>. Keep the using namespace std;, otherwise you'll have to use std::cout and the like instead of plain cout (and the like). If it still doesn't work, umm, make sure you're using a C++ compiler, not a C one?
    *** TITANIC has quit (Excess Flood)

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Any particular reason you're using DJGPP (are you running under DOS?)

    I recommend Dev-C++ for a free IDE/compiler, or perhaps MSVC++ Express 2005.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    4

    thanks

    djgpp is supposed to do c++ thanks for the info on iostream and the namespace line... i was using djgpp because i tried dev-c++ and got an error with my shell.dll when i ran it... i checked and its there and downloaded another one to replace the old one and still the error... i skipped over visual cause the compiler section said somthing about it being expensive... i downloaded it now and didn't have to pay anything will i have to pay later or something? either way seems to be working fine havn't done much with it yet as learning new things and hangovers don't mix... thanks for the help hopefully my program will build now when i get to it later tonight.
    Last edited by akbigchillin; 04-23-2006 at 04:19 PM.

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    AFAIK all the "express" products by microsoft are entirely free. If you want a full version of visual studio, it can get quite expensive (and actually, there are several versions)

    I bought VS 2003 through the local community college and was able to get an "academic" version (which I think is basically the same as the standard version) for a pretty good discount. I believe that even high school students can now get the academic versions through "authorized education resellers" such as a college bookstore, though I'm not entirely sure.

    As far as Dev-C++ goes, we _might_ be able to help (if you give more info), or you could go here for help with Dev.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    4

    dev-c++

    well i just got a new comp so i might try out dev-c++ again just to see if it works... which would you consider to be a better program? i think the problem with my shell.dll on my old comp was probably related to a trojan or virus or something... my old comp is absolutly fubar.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 02:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10:15 PM
  3. Problem with cout
    By kristentx in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2006, 01:37 PM
  4. 'cout' undeclared indentifier?
    By axon in forum C++ Programming
    Replies: 15
    Last Post: 09-22-2003, 04:48 PM
  5. I'm REALLY confused. Why isn't cout or cin working here?
    By niudago in forum C++ Programming
    Replies: 8
    Last Post: 02-15-2003, 05:53 PM

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