Mail Archives: djgpp/1999/12/06/14:28:04
In our last episode <384BC579 DOT A9D8FA05 AT hotmail DOT com>,
the lovely and talented knoriko A <knoriko_a AT hotmail DOT com>
broadcast on comp.os.msdos.djgpp:
|Hello again.
|
|I learned about DOS Edit FINALLY, and could read readme.1st. Thank you.
| I gave up on RHIDE and used Edit to type "hello world." I did exactly
|as directed in "Your First Program" guide, however, it didn't work and
|printed a line like this:
|
|hello.c:l: '#include' expects "FILENAME" or <FILENAME>
|
|So I tried :
|
|#include <hello.c>
No, it is highly unlikely that what you want to do is
to include the file itself.
What you want to include is the header for whatever
you are using for I/O.
Probably this is either:
#include <iostream>
if you are using cin
or
#include <stdio.h>
if you are using some form of print
|
|then gcc printed:
|
|hello.c:1: hello.c: No such file or directory (ENOENT)
|
|I'd really appreciate it if anyone could see the source below and let me
|know of any mistake.
|
|***********************************
|
|#include
#include <stdio.h> is what you want here since you are
using printf. Printf is not part of C. It is a library function.
So you have to tell the compiler about it. That is what the
header does. You could actually copy stdio.h into your program
file at this point to tell C what it needs to know. #include
is just a more convenient way for you to do that.
|
|int main(void)
|{
| printf("Hello, world!\n");
You see, C does not know how to printf. Fortunately someone
has written printf for you and put it in a nice library.
But you have tell C about it. The header file is what
you are including. That tells C what it needs to know
about the printf function so that your program will be
compiled to interact properly with the binary in the
library. The linker will then get the necessary binary
from the library and slam it into your program. Don't
worry too much about the linker at first -- it will all
happen seamlessly when you compile a simple program to an
.exe. The main thing is that a header file gives the
compiler essential information about functions that
are used by your program but which are not part of your
program.
| return 0;
|}
|
|***********************************
|
|Regards,
|knoriko
|
|
|
|
--
Lars Eighner 700 Hearn #101 Austin TX 78703 eighner AT io DOT com
(512) 474-1920 (FAX answers 6th ring) http://www.io.com/%7Eeighner/
bookstore: http://www.io.com/%7Eeighner/bookstore/
A radical is a man with both feet firmly planted in the air.
-- Franklin D. Roosevelt --
- Raw text -