LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   C++ Tutorial (https://www.linuxquestions.org/questions/linux-newbie-8/c-tutorial-290540/)

dlublink 02-15-2005 11:06 AM

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

Matir 02-15-2005 12:35 PM

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.

Tinkster 02-15-2005 12:57 PM

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

reddazz 02-15-2005 01:05 PM

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;
}

harken 02-15-2005 01:40 PM

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


All times are GMT -5. The time now is 10:42 AM.