Bill Cunningham said:
Jens Thoms Toerring said:
A) There is no prototype for isalpha() in scope, you forgot to
include <ctype.h>
B) isalpha() expects an int (typically a char, cast to int) as
its argument, but you pass it a pointer to a string.
[snip]
Thanks Jen. I've never used of thought of ctype.h.
And that's a symptom of the problem that's preventing you from
learning to program in C.
You know about the isalpha() function. I don't know where you learned
about it, but that doesn't matter.
If you had looked it up in any decent reference book, you would have
discovered that you need to add "#include <ctype.h>" to any source
file in which you use isalpha(). (A reference book that doesn't tell
you this is, by definition, not a decent one.)
Every standard library function is declared in some standard header.
Every time you use a standard library function, you must have a
#include directive for the header that declares it. Every time.
[Yeah, I know you don't always absolutely have to do this, but you
always should, and I'm simplifying just a wee bit.]
The above applies to all C programmers. The following is specifically
for you, Bill.
Every time you want to use a function from the standard C library,
whether it's fopen, fclose, printf, fprintf, isalpha, or anything
else, LOOK IT UP FIRST. Have the documentation for the function in
front of you, and read and *understand*:
what the function does;
the meanings and types of its arguments;
the meaning and type of its return value;
and the header in which it's declared,
before you even consider typing the first letter of the function's
name.
Don't use a function without knowing where it's declared. Don't use a
function without understanding what it does. Don't compare a
function's return value to NULL until and unless you *know* that it
returns a pointer, and what a NULL result means.
I have to look this stuff up myself. I honestly couldn't tell you
with certainty off the top of my head the order of the parameters for
fwrite(). (I just now checked the man page, and found that I had
mentally reversed the second and third parameters.)
If you can learn that lesson (and *retain* it), you'll have made some
actual progress.