LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-15-2005, 12:06 PM   #1
dlublink
Member
 
Registered: Oct 2004
Location: Canada
Distribution: Ubuntu
Posts: 329

Rep: Reputation: 30
C++ Tutorial


Hi,

I am trying to learn C++. But I cannot seem to get the most basic program compiled.


I say #include < stdio.h >

and it says it cannot find it when compiled with gcc or cc.

if I do whereis stdio.h
it says
/usr/include/stdio.h

if I put the full path in the include statement, I get the same error. Someone please help.

David

Last edited by dlublink; 02-15-2005 at 12:19 PM.
 
Old 02-15-2005, 01:35 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 123Reputation: 123
it should be:
Code:
#include &lt;stdio.h&gt;
though if you're trying to do c++, it should just be &lt;stdio&gt;.

The full path will never work with &lt;&gt;, you'd want to just use "".

If it still doesn't compile, you might have to specify -I/usr/include, though you shouldn't have to.
 
Old 02-15-2005, 01:57 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by Matir
it should be:
Code:
#include &lt;stdio.h&gt;
though if you're trying to do c++, it should just be &lt;stdio&gt;.

The full path will never work with &lt;&gt;, you'd want to just use "".

If it still doesn't compile, you might have to specify -I/usr/include, though you shouldn't have to.
Are you SURE that it will like the html tags instead of
the < and > ?



Cheers,
Tink
 
Old 02-15-2005, 02:05 PM   #4
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
You seem to be using C header files instead of C++. In C++ a simple hello world app would be similar to the one below.

#include <iostream>
using namespace std;
int main (void)
{
cout << "Hello, World!\n";

return 0;
}
 
Old 02-15-2005, 02:40 PM   #5
harken
Member
 
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
Use #include <cstdio> instead of #include <stdio.h>
If I'm right, stdio is deprecated.
 
  


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
QT tutorial vinsky2002 Linux - Software 2 03-02-2005 04:15 AM
looking for a tutorial!!! mio_carpe Linux - Networking 2 01-29-2005 03:29 PM
Need help w/tutorial FreakboY Programming 10 05-10-2004 06:30 PM
Tutorial Marklar Linux - Networking 11 12-20-2003 08:44 PM
How about a weekly tutorial? or just a tutorial Alinuxnoob LQ Suggestions & Feedback 2 04-09-2002 09:30 PM


All times are GMT -5. The time now is 08:54 AM.

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