Yep, code tags are done correctly.
Originally posted by simple
Ok i went ahead and made some of the changes to the code...i think its getting closer. thanks again for all the help. Hopefully i set up the code tags right this time!
I will add comments to your code as I correct it.
Take it from there and see what you can do.
For your first examples globals are
fine, but generally you want to avoid
global variables in most situations.
It makes your code easier to read
if the variables a function uses are
actually in that function.
int word_count = 0;
int letter_count = 0;
int next_word = 0;
printf("Please type a sentince\n");
You don't do anything with the
return value of your function here.
You probably want to do
something with it, like store it in
a variable so you can print it
later. Otherwise, if you don't ever
plan on using the return value,
you may as well use a 'void'
for your function instead of making
it return an 'int'.
Again, you need to add a line so
your main function returns a
value. This should do:
while (chr != EOF; chr != isspace(chr); chr != ".")
Your while( ) loop is wrong.
If you want to test for all of
these values, you will need to
use the following:
while( char != EOF && !isspace(chr) && chr != '.' )
Here, we use the "&&" expression
to test for more than one
expression. Not the ; as you
Additionally, when testing for
a single character value, you
use single quotes instead of
double quotes: ' not "
This next line does nothing.
letter_count = letter_count +1;
'If' should be 'if'. Do not use
a capital I.
For testing truth values, you
use the == and not =. The =
is used to assign a value to a
variable. == is used to check