01-28-2009, 11:19 PM #1cin, cout recognized with <stdio.h>, not with <stdio>
I am working on a fairly simple C++ application as a "terminal utility" (i.e. no GUI). When I try to compile my application, I get the following error:
cin.getline(str,100); //this is the line of source
error: 'cin' was not declared in this scope
If I change the include statement from
then I get a warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 22.214.171.124 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h> etc.
However, the program compiles and runs. So, my question: why doesn't the recommended header (<iostream>) work in this context?
01-29-2009, 11:48 PM #2
01-30-2009, 12:14 AM #3
- Member Since
- Mar 15, 2007
- 17" MacBook Pro, 2.33GHz C2D, 2GB RAM
Actually, in C++, #include <iostream> is the recommended method.
To the original poster, I suspect your problem is that when you include <iostream>, cin is in the std namespace and you may not be using that namespace (whereas iostream.h does the latter for you). If you either use std::cin.getline(...) or add the line using std::cin or the line using namespace std, or in some other way use the namespace "std" to find "cin", the <iostream> version will probably compile and work for you.
01-30-2009, 09:14 AM #4
01-30-2009, 09:36 AM #5
Thanks. Adding the line
using namespace std;
at the beginning worked fine.
02-10-2009, 09:46 AM #6
- Member Since
- Jan 27, 2009
in objective c which is similar to c++ it would be #include<iostream.h>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By mk ii in forum OS X - Development and DarwinReplies: 0Last Post: 01-24-2013, 05:40 PM
By kevinwwfg in forum Internet, Networking, and WirelessReplies: 4Last Post: 12-06-2010, 04:56 PM
By coreymc in forum OS X - Operating SystemReplies: 11Last Post: 10-03-2007, 10:54 PM
By Marie_A in forum OS X - Operating SystemReplies: 1Last Post: 09-15-2006, 07:15 AM
By lzco in forum OS X - Development and DarwinReplies: 6Last Post: 10-21-2005, 04:23 PM