Question:
What is wrong with my program?
Street Smart
2009-09-26 09:03:17 UTC
I have just written a simple C program in my Ubuntu Linux and tried to compile it.

The program is as follows:

#include

main()
{
printf("This is a C program\n");
}

I typed gcc -o newfilename sourcename.c

However. after that I got this:

sourcename.c:1:19: error: stdio.h: No such file or directory
sourcename.c: In function ‘main’:
sourcename.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

and it wouldn't compile.

Why is it it stated there is no stdio.h file? Isn't this file a standard file in C? Why did it also state "incompatible implicit declaration of built-in function ‘printf’"? Isn't the command printf a standard command in C?

What went wrong with my program?

Thanks in advance. I am only a novice.
Four answers:
2009-09-30 22:57:06 UTC
Hm....



















I m not friendly with gcc compiler.

But i know whats wrong: missing files stdio.h.

I think this file doesnt exist at path environment gcc compiler.

Or doesnt exist in /include dir
rinkiewicz
2017-01-18 23:24:29 UTC
that's stressful to tell what's incorrect with out comprehend-how what's going on. Does it fail to convey at the same time? in that case, what are the errors messages? does no longer it hyperlink? returned, what are the errors messages? Does it abort at a similar time as working? With what indicators? Does it produce incorrect output? What does it look like? What enter replaced into given, additionally? an excellent form of stuff shall we consistently wager at with out comprehend-how for specific. Sorry. playstation : a handbook: as a replace of a struct CIRCLE and 2 one-technique instructions, why now no longer make a classification CIRCLE which now no longer basically contains the parameters, yet the two ideas? that's between the beneficial factors of merchandise-oriented programming: the encapsulation of archives and ideas that carry out on the ideas.
CheesenBranston
2009-09-26 09:13:42 UTC
You may find an answer here

http://cboard.cprogramming.com/c-programming/90976-error-stdio-h-no-such-file-directory.html



The printf error is related to the fact that the compiler can't find the stdio.h library which includes the printf function/method.
2009-09-26 09:14:13 UTC
sudo apt-get build-essential

in terminal


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...