Trouble compiling on SUSE 13.2

I've been programming on windows with DevC++ for a while and wanted to try some things on linux. I'm running SUSE 13.2 and installed gcc and Kdevelop.

Now Kdevelop says iostream is not found and gcc says ‘printf’ was not declared.

Below is the most simple code I could write, someone please tell me how to start figuring out what I need to check on to get started.

Thx

1
2
3
4
5
6
7
8
9
// #include <fstream>
#include <iostream>
// using namespace std;

int main ()
{
printf ("hello");
return 0;
}


The error I get is
1
2
3
4
5
6
7
sam@linux-56:~/temp> gcc test.cpp -o test1
test.cpp: In function ‘int main()’:
test.cpp:7:16: error: ‘printf’ was not declared in this scope
 printf ("hello");
                ^
sam@linux-56:~/temp>
if your tying to compile a c++ program then you need to use g++ not gcc. g++ is the c++ compiler gcc is a c compiler. if you want to use printf in your program then you need to include #include <cstdio> for c++ programs or #include <stdio.h> for c programs.
http://www.cplusplus.com/reference/cstdio/
Thanks, it works.

Topic archived. No new replies allowed.