Hi 
Thank you for your help.I'm a beginer on cpp. I'm programming in windows/dos
mode and i get error when i compile the program 
#include <iostream>
int main(){
std::cout << "olare" << std::endl;
}
I get error when i compile the program with gcc ola.cpp -o ola.exe
Can you help me?
Thank you

Axel Freyn wrote:
> 
> Hi,
> On Thu, May 29, 2008 at 03:08:34AM -0700, Lopezio wrote:
>> #include "iostream"
>> int main(){
>> printf("olare");
>> return 0;
>> }
>> I get error when compile it with gcc ola.cpp -o ola.exe but it works in
>> rhide environment. 
> Well, your example is neither valid C-code, nor valid C++-code:
>  - iostream belongs to C++, and not c
>  - printf is declared in stdio.h, for C
>  - you should use #include <iostream> instead of "iostream". With "", gcc
>    searches only in the current directory (and in all directories given
> given as
>    include directories on command line)
>  - the filename should end on ".c" instead of ".cpp". ".cpp" is understood
> as
>    C++-code by gcc
>  - If you see nothing in the output: add a newlin "\n" to the
> printf-command
>  - If you compile using "gcc", the compiler does not link to the
> C++-libraries.
>    use "g++" instead.
>    
> If you use (C-version, ola.c)
> #include <stdio.h>
> int main(){
>  printf("olare\n");
>  return 0;
> }
> it should work with  gcc ola.c -o ola.exe. This also works with 
> g++ ola.c -o ola.exe
> or as
> gc ola.cpp -o ola.exe
> if you want
> 
> As C++ version, I would propose (in ola.cpp):
> #include <iostream>
> int main(){
>   std::cout << "olare" << std::endl;
> }
> with
> g++ ola.cpp -o ola.exe
> 
> 
> The "best" programming environment depends on what you like - I'm using
> vim
> 
> HTH,
> 
> Axel
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Program-editor-programming-c%2B%2B-tp17532397p17545760.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

Reply via email to