PDA

View Full Version : Geany C++ HELP!!



Ch0p5t1ckB01
April 9th, 2007, 05:54 PM
Hi, I just recently started to use Geany. Previously using Bloodshed Dev-C++ and love it.
When I was trying it out with a "Hello World" printf statement. My compiler gives me an error. Can someone help me out?

Here's my code:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
main()
{
printf("Hello World");
system("pause");
}


This is the error I get:

gcc -Wall -c "untitled" (in directory: /home/ch0p5t1ckb01)
gcc: untitled: linker input file unused because linking not done
Compilation finished successfully.

Does not allow me to execute the file.

Any help is greatly appreciated!!

DoubleQuadword
April 9th, 2007, 06:48 PM
Does not allow me to execute the file.

Because you're providing the 'compile only' option to the compiler. Try doing this:


gcc -Wall untitled

Please note the fact that this option '-c' is missing.



main()
{
printf("Hello World");
system("pause");
}


Try to declare your main function this way:



int main (int, char **) or int main (int, char*[])


Both arguments and the return type are important.


system("pause");

If you're planning to execute this application in Linux try to remove that line. 'Pause' is a Microsoft DOS command not a one supported in Bash.

Regards.

maddog39
April 9th, 2007, 08:17 PM
Um acutally its just because you didnt save the file before hand. You might want to use:

system("sleep 1");
for a replacement to the PAUSE command in dos.

samjh
April 10th, 2007, 07:06 AM
Or else use getchar() instead of system("whatever").

With getchar() you just have to press a key, so you can stare at the greeting and feel really good for as long as you want. :p

slavik
April 10th, 2007, 02:55 PM
press F9 to actually build the file (where it also links), F8 only compiles (to check for syntax errors)

and remove that system()/getcahr() nonsense, if you have latest geany it will put in appropriate wrapper code to keep the shell open.

Rosver
January 7th, 2009, 03:26 AM
Wow, Slavik. I also had the same problem. Your solution works quick. Ha ha ha. I feel foolish for making such a small error.

efexD
January 7th, 2009, 03:47 AM
PLEASE don't ever use system()

Zugzwang
January 7th, 2009, 10:25 AM
PLEASE don't ever use system()

Reason?

Sinkingships7
January 7th, 2009, 07:49 PM
Reason?

Not cross-platform and relies too much on the outside world. Trivial and irrelevant for this situation, but foolish to use in a larger program where there's an alternative.

hundredwatt
January 7th, 2009, 10:50 PM
Not cross-platform and relies too much on the outside world. Trivial and irrelevant for this situation, but foolish to use in a larger program where there's an alternative.

Try this instead:


cout << "Press enter to continue..";
cin.get();

C_Bomb
December 23rd, 2010, 08:43 PM
okay, well what about clearing the screen and all the other functions?

I'm also new to C++ for Linux.

My program works perfectly fine in Windows, but in Linux I get errors to the system() commands.