tags:

views:

160

answers:

1

Hello everyone, I am a beginner in C++

I am average at C.

I have written the following code in C++ (file.cpp)

#include <iostream>

int main(){

   std::cout<<"My name is ANTHONY";
}

Then I tried to compile the above code using cpp file.cpp but got some errors. I don't know whats wrong

When I tried to compile my C program (changed <iostream> to <stdio.h> and std::cout to printf) using cc file.c, I didn't get any errors.

What is happening here?

+16  A: 

Then I tried to compile the above code using cpp file.cpp but got some errors.

That is because cpp is C(C++) preprocessor. It is a separate program invoked by the compiler (g++) as the first part of translation.

Try compiling your code using g++ file.cpp. :)

Prasoon Saurav
I say. Good catch, old chap.
paxdiablo
@paxdiablo : Haha,thanks =)
Prasoon Saurav
Oh my god, very good catch I must say. Thnx
Anthony