473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

problem with <iostream>

Hi All. i am new to C++. I know that in order to use cout, i need to
include <iostream>. I have done this, but i still get errors when i try
to output to the screen. Is there a file that needs to reside in the
same folder as the project? I know that in java, this is the case.
Please help.
Thank Wesley

Jun 5 '06 #1
5 2311
<we****@ispace.co.za> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
: Hi All. i am new to C++. I know that in order to use cout, i need to
: include <iostream>. I have done this, but i still get errors when i try
: to output to the screen. Is there a file that needs to reside in the
: same folder as the project? I know that in java, this is the case.
I don't think so.

What kind of errors are you seeing ?
I would think that these are compilation errors.

Try starting with the following program:
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Hello" << endl;
string s;
getline( cin, s); // read some user input
return 0;
}

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Jun 5 '06 #2
we****@ispace.co.za escribió:
Hi All. i am new to C++. I know that in order to use cout, i need to
include <iostream>. I have done this, but i still get errors when i try
to output to the screen. Is there a file that needs to reside in the
same folder as the project? I know that in java, this is the case.
Please help.
Thank Wesley


My guess is that you forgot the namespace, remember that you have to
call cout by:

std::cout << "chocolate" << std::endl;

If you dont want to use 'std::' all the time, read this:
http://www.parashift.com/c++-faq-lit....html#faq-27.5

- Eduardo Grajeda
Jun 5 '06 #3

<we****@ispace.co.za> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Hi All. i am new to C++. I know that in order to use cout, i need to
include <iostream>. I have done this, but i still get errors when i try
to output to the screen. Is there a file that needs to reside in the
same folder as the project? I know that in java, this is the case.
Please help.
Thank Wesley


std::cout << "Hello World!" << std::endl;

or

using namespace std;

void writescreen(void) {
cout << "Hello World!" << endl;
}

When using cout the text will be flushed to screen whenever there is a
std::endl or when you call flush.

You might wanna take a look at http://www.cplusplus.com/ref/iostream/

//eric
Jun 5 '06 #4
Your program works, i tried something similar, but it did not work, I
left out the #include <string>. The include and cout were underlined by
eclipse. Thanks for your help
What kind of errors are you seeing ?
I would think that these are compilation errors.

Try starting with the following program:
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Hello" << endl;
string s;
getline( cin, s); // read some user input
return 0;
}

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com


Jun 5 '06 #5
Thanks guys, i actually did forget the namespace. I am abit rusty with
C++.
Thanks Wes

Jun 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give...
1
by: Juergen Marsch | last post by:
Hi, writing files > 2G with standard library iostream classes results in "... file size limit exeeded." Compiling my program with "-D_FILE_OFFSET_BITS=64" doesn't make any difference. If you...
9
by: ai | last post by:
Hi , I have an application which has to read files of size few mba nd read them into array . Since i am using STL and std namespace to avoid the error error C2872: 'ifstream' : ambiguous...
4
by: aurgathor | last post by:
Howdy, What would be the equivalent of getch() using iostream? My current code is: cout << "\nPress <Enter> to continue..."; getch(); but <conio.h> is not kosher for the C++ class.
1
by: zerotyNONONOTHERESNOSPAMMING!type | last post by:
Hi, As most of you probably already know, depending on which implementation of C++ you have, #include <iostream> may cause various other headers to be #included too. (I've observed cstring,...
2
by: Brett | last post by:
Hi, I'm compiling an old project under the 'new' visual studio 7.1.3088. I changed the line: #include <iostream.h> to #include <iostream> and now I get a stack of errors, some of which...
9
by: nichas | last post by:
I tried to use #include<iostream> in visual C++ compiler but then it didnt work but i see this is the way it is being mentioned in C++ primer by lippman and lajoie.. where is the problem.. Do...
1
by: Old Wolf | last post by:
In a discussion elsewhere, someone wrote: #include <iostreamis not guaranteed to define std::cout, it merely has to declare it as an extern object, and declarations of extern objects do not...
11
by: gumboots | last post by:
Hi there guys, I've recently purchased "Sam's Teach Yourself C++ Fifth Edition" (About a week before the 6th edition came out) I'm trying to work through the book, but in trying to compile Hello...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.