[Courses] [C] Lesson Three: Basic Declarations & Expressions
Eugene Teo
eugene.teo at eugeneteo.net
Fri Oct 11 00:39:43 EST 2002
<quote who="KWMelvin">
u> #include <stdio.h> /* Standard C Library header file */
u> #include "myheader.h" /* contains my declarations, etc. */
u>
u> I do not know what an #ifdef is. Would you mind elaborating
u> on that? We'll get into the C Preprocessor in Chapter 9 of
u> the book, but I don't see how it could hurt to learn something
u> about it now? Thanks in advance. -- K
----- in myheader.h -----
#ifndef _MYHEADER_H_ // if not _MYHEADER_H_ is not defined
#define _MYHEADER_H_ // then define it
#include <pthread.h> // define whatever headers you need
...
#endif // end if
----- in mainproggie.h -----
#include <stdio.h>
#ifndef _MYHEADER_H_ // if myheader.h is included, _MYHEADER_H is
#include "myheader.h" // defined, so we won't include anymore. once
#endif // is enuff. if not, we include myheader.h.
also, for the main(), it takes no parameter and returns an integer by
default, so there is no need to explicitly do "int main(void)". just
main() will do.
One advice I can give is to learn to write routines like test integers,
doing [A-Z] to [a-z] conversions, etc. man ascii and you will be
enlightened.
Ok just for the fun of it, you might want to try to compile
my one-liner:
main(i){putchar(182623909>>(i-1)*5&31|!!(i<7)<<6)&&main(++i);}
:-)
Anyone has any notes to share on the following topics?
Graph diagrams on multiple fork calls, with pipe and dup2?
I am learning these now, and kind of confused when it deals
with more than 3-4 fork()s, especially when it comes to
identifying who are children, grandchildren, etc.
Eugene
--
eMail: eugeneteo at eugeneteo.net, eugeneteo at null.cc.uic.edu
gpg pub_key: http://null.cc.uic.edu/~eugeneteo/eugeneteo.asc
main(i){putchar(182623909>>(i-1)*5&31|!!(i<7)<<6)&&main(++i);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://linuxchix.org/pipermail/courses/attachments/20021011/8f76a280/attachment.pgp
More information about the Courses
mailing list