cout and cin objects of iostream class

i ran the following code in the latest version of code::blocks and it tells me that the objects cout and cin are not declared in this scope. what is the problem?

I used to use Turbo C++ 3.0 and i had no problem whatsoever with that compiler. But now i am trying to move to code::blocks but it is proving very very hard as all the standards have been changed.

I am a school student and thus, we had been told to practice on Turbo C++ 3.0 and now i am unable to unlearn it. Also, if i use printf in place of cout there is no error but i want to use cout as it is what i am comfortable working with.

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

#include<fstream>
#include<conio.h>

int main()
{
using namespace std;

char name[20];
cout<<"\nEnter your name:";
cin.getline(name,20);

cout<<"\nName has been stored";
getch();

return 0;
}


Please help me with this issue. Is there some document to which i can refer so as to get the latest C++ standards which is C++0x i believe?
#include <iostream>
common, fstream has everything from iostream. I changed the code anyway and the following code says that: clrscr() is not declared in this scope. What is the problem. WHy cant they just keep it simple?!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

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

int main()
{
    using namespace std;

    clrscr();

    char name[20];

    cout<<"\nEnter your name:";

    cin.getline(name,20);

    cout<<"\nName stored";

    clrscr();

    cout<<"\nName:"<<name;

    getch();
    return 0;

}
common, fstream has everything from iostream.

No, it does not.


clrscr() is not declared in this scope.

Likely because there is no such function.
it is declared inside conio.h.

you do know what you are taking about right?
you do know what you are taking about right?


Yes. And you would too if you bothered to open up conio and search for clrscr or utilize google.

Do not expect nonstandard stuff from the horribly outdated Turbo C++ to magically work on other compilers.
Interesting... how can you be so sure " fstream has everything from iostream", if you just simply search for these two libraries, they are totally different, I wonder if fstream would provide cout / cin functions.

For the clrscr() problem, this function is not part of the C++ standard.
clrscr was available in the ancient Turbo C++.

@andywestken
(There is no general C++ way to solve the problem; if you need the functionality you'll require either platform specific solution or a console library (e.g. CURSES).
The Windows console API is not the friendliest API, but Microsoft Support do provide a code snippet:
How To Performing Clear Screen (CLS) in a Console Application
http://support.microsoft.com/kb/99261))
are you telling me that the fucntions have been changed?

is that why everyone is so inclined on using

1
2
3

system("cls")


so, all of you guys are saying that i would have to unlearn everything i have learned for Turbo C++ till now and learn all the header and library functions et al again all over from the beginning?!
Topic archived. No new replies allowed.