PDA

View Full Version : Something is wrong with my program



Bob John
January 4th, 2009, 02:23 AM
I wrote a program to judge a number is prime or not.
"prime" here means a number that can only be divided by itself or one.
When I compiled it by gcc , the error message came up.And I do not very understand the message , so the compiling progress always can't complete.I checked and checked , modified and modified ,but I can't accomplished all the time.
Could you please help me to correct it?
Thank you .
Here is the source code , written in C :

98624
Here is the error message provided by gcc :

98625

bruce89
January 4th, 2009, 02:38 AM
You're not linking to libm. Use -lm in the gcc command line.

In future, post your source and errors as text, not a screenshot.

jpmelos
January 4th, 2009, 02:40 AM
In future, post your source and errors as text, not a screenshot.

Seconded. Makes it easier for us who want to help to just copy and try to compile the code (if the error is in the code). :)

monkeyking
January 4th, 2009, 02:44 AM
It also makes it easier for catching errors if you compile with -Wall .
You wouldn't have caught this one though...

Bob John
January 7th, 2009, 10:31 AM
Thanks , everyone .

Later I will put all the code in text type.

These two days, I was too busy to log in our ubuntu forum.

Source code text format will come soon ...

Bob John
January 7th, 2009, 11:03 AM
Thanks Everyone!My problem is solved now.

It is right to link to libm.a or type -lm in the gcc command line.

Thank you everyone ! These useful reply were thanked just before. ^_^