Am in need of help.

Am in need of help.

Post by BlackDecibel on Tue Apr 17, 2012 12:08 pm
([msg=65723]see Am in need of help.[/msg])

Firstly, yes, I am a newbie to Linux, just another newbie. I'm on Ubuntu. I'm loving it. It is tons better than Windows (but less applications, eh, not fussy)
I haven't yet made a huge convert from Windows to Linux because it is on my CD. I will be, anyway. :D

I am currently learning about C++ via reading through a book.

The problem is, it's the compiler. I got the error after the attempt to compile. It is this: "fatal error: isostream: No such file or directory
compilation terminated." (Latest version - 4.6.1).

What is going on? I've googled everywhere and found of no hope. So I thought I should post it here and hopefully you guys can help me!

Many thanks! :)
BlackDecibel
New User
New User
 
Posts: 4
Joined: Sun Apr 15, 2012 3:26 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by fashizzlepop on Tue Apr 17, 2012 12:19 pm
([msg=65724]see Re: Am in need of help.[/msg])

Post the code.

Also, are you including <iostream> or "iostream" or <iostream.h> or "iostream.h"?
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by BlackDecibel on Tue Apr 17, 2012 12:31 pm
([msg=65725]see Re: Am in need of help.[/msg])

fashizzlepop wrote:Post the code.

Also, are you including <iostream> or "iostream" or <iostream.h> or "iostream.h"?


#include <iostream>
using namespace std ;

int main()
{
count << "Hello World!" << endl ;
return 0 ;
}


Here it is! A simple hello world.

Ah, so am I supposed to change the <iostream> to <iostream.h>? I'm gonna try all of that. EDIT: No luck.
BlackDecibel
New User
New User
 
Posts: 4
Joined: Sun Apr 15, 2012 3:26 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by ghost107 on Tue Apr 17, 2012 2:44 pm
([msg=65727]see Re: Am in need of help.[/msg])

BlackDecibel wrote:
#include <iostream>
using namespace std ;

int main()
{
count << "Hello World!" << endl ;
return 0 ;
}


The code looks good, only problem is you wrote count instead of cout.
ghost107
Poster
Poster
 
Posts: 132
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: Am in need of help.

Post by BlackDecibel on Tue Apr 17, 2012 4:00 pm
([msg=65731]see Re: Am in need of help.[/msg])

ghost107 wrote:
BlackDecibel wrote:
#include <iostream>
using namespace std ;

int main()
{
count << "Hello World!" << endl ;
return 0 ;
}


The code looks good, only problem is you wrote count instead of cout.

Strangely, that fixed the problem. Thanks for spotting that out anyway! :lol:
BlackDecibel
New User
New User
 
Posts: 4
Joined: Sun Apr 15, 2012 3:26 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by LoGiCaL__ on Tue Apr 17, 2012 6:11 pm
([msg=65736]see Re: Am in need of help.[/msg])

better off using std::cout <<
drop using namespace std
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1062
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by WallShadow on Tue Apr 17, 2012 7:31 pm
([msg=65739]see Re: Am in need of help.[/msg])

LoGiCaL__ wrote:better off using std::cout << <br>drop using namespace std


Really? Why would you drop the namespace std? It makes it much easier to work with a program with a million cout << and endl.
User avatar
WallShadow
Contributor
Contributor
 
Posts: 602
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by ghost107 on Tue Apr 17, 2012 8:45 pm
([msg=65740]see Re: Am in need of help.[/msg])

BlackDecibel wrote:Strangely, that fixed the problem. Thanks for spotting that out anyway! :lol:

You should try to read your compiling output, to catch syntax errors(and understand them).

The difference between "using namespace std" and "std::" is that you load all the std types globally(especially if you declare it in header files), an alternative is to use the using method in the functions and the specified type (that you need)by calling "using std::"

Example:
Code: Select all
#include <iostream>

int main()
{
    using std::cout;//for printing
    using std::endl;//for new line, I usually use '\n'
    cout << "Hello World!" << endl ;
    return 0 ;
}

Or what LoGiCaL__ said, but for small projects or for beginners I say using namespace std is still good to use.
ghost107
Poster
Poster
 
Posts: 132
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: Am in need of help.

Post by WallShadow on Tue Apr 17, 2012 11:56 pm
([msg=65742]see Re: Am in need of help.[/msg])

Yes, I agree. However on a different topic, isn't "using std::cout;" supposed to be outside main()? I'm not entirely sure if functions declared in the file can use cout if you reference cout only in the main. And personally, I used to also use '\n' all the time, but endl just makes it more readable.
User avatar
WallShadow
Contributor
Contributor
 
Posts: 602
Joined: Tue Mar 06, 2012 9:37 pm
Blog: View Blog (0)


Re: Am in need of help.

Post by ghost107 on Wed Apr 18, 2012 4:05 am
([msg=65745]see Re: Am in need of help.[/msg])

It can be used locally or globally, in the example above it was an example using it locally, if you have many functions you can declare it outside the function(globally,but not in header files).
ghost107
Poster
Poster
 
Posts: 132
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Next

Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests