LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2005, 05:40 PM   #1
Bondfire
LQ Newbie
 
Registered: Jul 2004
Posts: 17

Rep: Reputation: 0
Help with C++ in Linux


Hi pple,

I have 3 questions re writing C++ programs in Linux.

1) Is there any help section about the C++ headers and functions available in g++ that i can refer to? I want to find out what header files contain which functions..for example outportb() in dos.h writes data to a port in Windows but the function becomes outb() in Linux and under a different header..how can i search under which header file this function falls in? Is there any help menu for g++? the man command only gives me help on linux commands

2) I tried writing my 1st C++ program in Linux but it didn't compile...until i found that i have to write #include <iostream> without the .h but as it is some1 gave me a C++ program in Lunix to me and in that program all headers have .h so how come i got a warning stating that iostream.h was deprecated?

3) I also found out that cout << doesn't work until i have \n at the end like
cout << " Hi \n"; ...why is it this way?

pls your help guys....i new to Linux..am using RedHAT 8.0

Thanks
Bondfire
 
Old 04-07-2005, 06:21 PM   #2
TruongAn
Member
 
Registered: Dec 2004
Location: Vietnam (Việt Nam)
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728

Rep: Reputation: 33
TO SOLVE ALL THE PROBLEM: I suggest you switch to use some IDE such as kdevelop.

1) To find out a list of function available in a .h file, just open this file to have a look.
For example if you open cmath.h, you can see that abs and sqrt function available in this file.

2) Switch to an IDE to deal with this problem

3) cout << must end with a line craft character, \n or <<endl.
 
Old 04-07-2005, 06:52 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,568

Rep: Reputation: 164Reputation: 164
Re: Help with C++ in Linux

Quote:
Originally posted by Bondfire
1) Is there any help section about the C++ headers and functions available in g++ that i can refer to? I want to find out what header files contain which functions..for example outportb() in dos.h writes data to a port in Windows but the function becomes outb() in Linux and under a different header..how can i search under which header file this function falls in? Is there any help menu for g++? the man command only gives me help on linux commands
More important functions and system functions have their manual pages with needed includes, syntax and description. Try 'man functionname'.

Quote:
2) I tried writing my 1st C++ program in Linux but it didn't compile...until i found that i have to write #include <iostream> without the .h but as it is some1 gave me a C++ program in Lunix to me and in that program all headers have .h so how come i got a warning stating that iostream.h was deprecated?
With the compiler from RH 8.0 you should get warning. It should also compile. Which version of g++ is it exactly?

Quote:
3) I also found out that cout << doesn't work until i have \n at the end like
cout << " Hi \n"; ...why is it this way?
cout data is buffered and printed when it gets a newline sign or when it's flushed, when the buffer is full and, I think, after a certain time. You can also make it unbuffered, but I'm wondering if that's what you really need. Do you need it unbuffered or it's just a question?
 
Old 04-07-2005, 07:01 PM   #4
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
here is a good recource for the functions included in the standard header files and what they do. gcc compiles standard c++, so as long as you use standard functions it should compile. i have never used and IDE, i prefer to program with textfiles and vi.
i don't know why cout wont work for you unless you use a \n. it does not have to have a \n at the end to work. if you leave off the new line character you just get your new command propt on the same line as the last line of your programs output. although, you do know that cout is in the std namespace and has to refered to as std::cout unless you use the

use namespace std;

at the top of your program right?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
link dies intermittently-seemingly at random- between win<->linux not linux<->linux?? takahaya Linux - Networking 10 03-09-2007 11:37 PM
triple boot linux/linux/linux No Windows involved toastermaker Linux - Newbie 12 03-02-2006 11:40 PM
Redhat (rhel v2.1) bootup problem with linux (linux vs linux-up) namgor Linux - Software 2 06-24-2004 03:49 PM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration