Greetings,
Thanks to everyone who is participating with comments and feedback.
Class participation is encouraged! Has anyone tried removing a
semi-colon from the end of a statement yet? What happened when you
re-compiled the program? I removed the semi-colon from the end of
the printf() line, and re-compiled the program. This is what I got:
~/src$ gcc -o testme testme.c
testme.c: In function `main':
testme.c:6: parse error before `return'
~/src$
Has anyone tried something else? If so, what? What happened?
I copied hello.c to testme.c so I could play with the program. The
printf() was on line 4, but the compiler didn't notice until it
reached `return' on line 6. `return' is a C keyword.
Speaking of C keywords, I'd like to list them here, all together.
They say that C is a `small' language. I count 32 keywords.
auto const double float int short struct unsigned
break continue else for long signed switch void
case default enum goto register sizeof typedef volatile
char do extern if return static union while
In addition to the reserved keywords, there are about 45 operators.
These are listed from highest to lowest precedence (we'll eventually
learn what that means).
Precedence Group HIGHEST
--------------------------------------------------------------------
function, array, structure member, () [] . ->
pointer to structure member
unary operators ++ -- + - ! ~ (type) * & sizeof
arithmetic multiply, divide, remainder * / %
arithmetic add and subtract + -
bitwise shift operators << >>
relational operators < <= > >=
equality operators == !=
bitwise AND &
bitwise XOR ^
bitwise OR |
logical AND &&
logical OR ||
conditional operator ? :
assignment operators = += -= *= /= %= &= ^= |= <<= >>=
comma operator ,
----------------------------------------------------------------------
Precedence Group LOWEST
There are about 76 C Standard Library functions! Before you re-invent
the wheel by writing your own function, take a look at what's already
been done.
* ctype.h
isalnum() isalpha() isascii() iscntrl() isdigit() isgraph() islower()
isodigit() isprint() ispunct() isspace() isupper() isxdigit()
toascii() tolower() toupper()
* malloc.h
calloc() free() malloc()
* math.h
acos() asin() atan() atan2() ceil() cos() cosh() exp() fabs() floor()
fmod() labs() log() log10() pow() sin() sinh() sqrt() tan() tanh()
* stdio.h
fclose() feof() fgetc() fgets() fopen() fprintf() fputc() fputs()
fread() fscanf() fseek() ftell() fwrite() getc() getchar() gets()
printf() putc() putchar() puts() rewind() scanf()
* stdlib.h
abs() atof() atoi() atol() exit() rand() srand() system()
* string.h
strcmp() strcmpi() strcpy() strlen() strset()
* time.h
difftime() time()
I sound like The Count on Sesame Street. ;-)
Everything added up comes to 153 more or less (I may have missed
something?). I guess C is a `small' language, indeed!
Happy Programming!
--
K
Thanks to everyone who is participating with comments and feedback.
Class participation is encouraged! Has anyone tried removing a
semi-colon from the end of a statement yet? What happened when you
re-compiled the program? I removed the semi-colon from the end of
the printf() line, and re-compiled the program. This is what I got:
~/src$ gcc -o testme testme.c
testme.c: In function `main':
testme.c:6: parse error before `return'
~/src$
Has anyone tried something else? If so, what? What happened?
I copied hello.c to testme.c so I could play with the program. The
printf() was on line 4, but the compiler didn't notice until it
reached `return' on line 6. `return' is a C keyword.
Speaking of C keywords, I'd like to list them here, all together.
They say that C is a `small' language. I count 32 keywords.
auto const double float int short struct unsigned
break continue else for long signed switch void
case default enum goto register sizeof typedef volatile
char do extern if return static union while
In addition to the reserved keywords, there are about 45 operators.
These are listed from highest to lowest precedence (we'll eventually
learn what that means).
Precedence Group HIGHEST
--------------------------------------------------------------------
function, array, structure member, () [] . ->
pointer to structure member
unary operators ++ -- + - ! ~ (type) * & sizeof
arithmetic multiply, divide, remainder * / %
arithmetic add and subtract + -
bitwise shift operators << >>
relational operators < <= > >=
equality operators == !=
bitwise AND &
bitwise XOR ^
bitwise OR |
logical AND &&
logical OR ||
conditional operator ? :
assignment operators = += -= *= /= %= &= ^= |= <<= >>=
comma operator ,
----------------------------------------------------------------------
Precedence Group LOWEST
There are about 76 C Standard Library functions! Before you re-invent
the wheel by writing your own function, take a look at what's already
been done.
* ctype.h
isalnum() isalpha() isascii() iscntrl() isdigit() isgraph() islower()
isodigit() isprint() ispunct() isspace() isupper() isxdigit()
toascii() tolower() toupper()
* malloc.h
calloc() free() malloc()
* math.h
acos() asin() atan() atan2() ceil() cos() cosh() exp() fabs() floor()
fmod() labs() log() log10() pow() sin() sinh() sqrt() tan() tanh()
* stdio.h
fclose() feof() fgetc() fgets() fopen() fprintf() fputc() fputs()
fread() fscanf() fseek() ftell() fwrite() getc() getchar() gets()
printf() putc() putchar() puts() rewind() scanf()
* stdlib.h
abs() atof() atoi() atol() exit() rand() srand() system()
* string.h
strcmp() strcmpi() strcpy() strlen() strset()
* time.h
difftime() time()
I sound like The Count on Sesame Street. ;-)
Everything added up comes to 153 more or less (I may have missed
something?). I guess C is a `small' language, indeed!
Happy Programming!
--
K