error :In function 'main':
Hi All,
Please i need ur help i compiled 2 examples and it s giving me the following error: In function 'main': pls how can it b solved?? Thanks |
This is not really enough information for anyone to help you. The actual error(s) will be on the line(s) displayed below 'In function main:'. All we can say from this is that you tried to compile something, which has a function called main, and there was an error in compiling that part of the code.
So - 2 examples of what? - what is the code you were trying to compile (you can post it here)? - what is the actual error (displayed below 'In function main:')? |
Hi,
"in function 'main':" is not an error, so there is nothing to be solved :) If you want to get a solution, please post the error! Cheers! |
actually, this is the error i m getting:
/tmp/ccydIKZQ.o: In function `main': csc1.c:(.text+0x288): warning: the `gets' function is dangerous and should not be used i ll supply u with the code when i go home does this kind of error make sense to u, did i get this error cz of the gets??? |
While not familiar with the function gets, that message is not an error as such, but a warning. Are you sure that the compile did not work? Look for a binary file nearby that wasn't there before.
If you have access to linuxquestions you have access to google. Googling 'gets function C' gave me this page as first choice: http://www.crasseux.com/books/ctutorial/gets.html Seems very clear to me. |
You should never use gets, as is explicitly stated in the man page. It is broken. Use fgets instead.
|
Thats not an error, thats a warning. Which means that you did get a succesful compilation. You'd probably missed the a.out binary which must be there.
Either way, soggycornflake is right. gets is a dangerous function (as the compiler said also :D ) because it doesnot check for a buffer overflow. So read the man for that function and search for an alternative (like fgets as, once again, soggycornflake stated before) Cheers! |
i run the program, as it seems it is executing correclty but i m afraid of these errors and i want to compile without getting any error or warning. I will change the gets to fgets and recompile it
Thanks ! p.s: can i just insert fgets instead of gets or i have to change it all ?? |
fgets requires the buffer size and a file stream, in addition to the buffer. RTFM!
Code:
char buffer[80]; Code:
char buffer[80]; |
Thank you i ll try it :)
|
Thanks :) i solved it :)
|
I'm also learning C. This seems a good tutorial:
http://www.crasseux.com/books/ctutorial/ |
Thanks a lot :)
|
All times are GMT -5. The time now is 05:25 PM. |