English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i am very new to c++ and programming in general.
i bought a book called c++ all in one desk reference for dummies.
i am a few pages in and im having trouble making words come up into a dos box.

im using a program called dev-c++

#include
#include

int main(int argc, char *argv[])
{
cout << "Hello, i am your computer talking." << endl;
system("PAUSE") ;
return 0;
}


when i enter that, the error box on the bottom of dev-c++ says

line 8 message: cout undeclared (first use this function)

line 8 message: endl undeclared (first use this function)

also, if i delete line 8 of that, it works fine, a dos box pops up and says press any key to continue.

if you could please give me a few tips upon what i might be doing wrong,
please tell me!

2007-03-11 04:54:55 · 6 answers · asked by geoff w 1 in Computers & Internet Programming & Design

6 answers

You need to either change line 8 to read:

std::cout << "Hello..." << std::endl;

Or add:

using namespace std;

After the #include lines.

You have to tell the compiler in what namespace to find cout & endl; the first does it explicitly, the second makes all names in the std namespace available in your program.

Edit to luv l: No, it's not , it's just . The standard library does not use .h for its headers; the .h versions are deprecated and should no longer be used, as they do not use the std:: namespace.

2007-03-11 05:19:25 · answer #1 · answered by Flyboy 6 · 0 0

firstly, about the cout thing. (i have dev-c++) change the line #include
to
#include

now you should be aware that a dos box will always pop up (unless you use win32, that's not the case however)
what the system("pause") function does is to display "press nay ...'

2007-03-13 08:19:07 · answer #2 · answered by Anonymous · 0 0

You need to specify that your working with the standard c++ namespace.

type in "using namespace std;" before your 'main' function.

alternatively, you could use std::cout <<" blah blah"; instead if you preferred, putting the std:: before every cout/ cin / any other standard function.

Im new to c++ too, sorry if my terminology is a bit worng.

2007-03-11 04:59:51 · answer #3 · answered by aswan k 1 · 0 0

#include
using namespace std;

int main()
{
cout << "Hello, i am your computer talking." << endl;
system("PAUSE") ;
return 0;
}

2007-03-11 05:38:51 · answer #4 · answered by iyiogrenci 6 · 0 0

This code will print 2 random integers on the stdout. printf("%d %d",i,j) will print a million 2 and printf("%d %d",j,i) will print 2 a million(because's the output you asked!).

2016-10-18 02:46:10 · answer #5 · answered by Anonymous · 0 0

its not iostream
its iostream.h
try this it will work

2007-03-11 05:48:31 · answer #6 · answered by luv l 1 · 0 0

fedest.com, questions and answers