E
ext_u
Ok I thought I would try to take the program one thing at a time. (If
you remember my last post I am trying to make a histogram with data on
the size of each word)
Anways first .. I obviously need to determine what a word actually is.
I wrote this program on my own without looking at the book or any
other resource once.
#include <stdio.h>
main()
{
int c;
int nword, nother;
nword = nother = 0;
while ((c = getchar()) != EOF)
{
if (c == ' ' ¦¦ '\t' ¦¦ '\n')
++nother;
else
++nword;
}
printf("Words = %d\nOther = %d", nword, nother);
}
I am basically just trying to tell the computer anything that is not a
blank space, a tab , or a newline is a word...
BUT everytime I run the program it adds to only the nother variable.
I can't figure out why, no matter what I type. I thought I had
written this program well and I even sketched it out on paper
beforehand , hehe.
I know you guys will probably find a horribly noobish mistake , but
please remember I started learning C all of like 48 hours ago.
you remember my last post I am trying to make a histogram with data on
the size of each word)
Anways first .. I obviously need to determine what a word actually is.
I wrote this program on my own without looking at the book or any
other resource once.
#include <stdio.h>
main()
{
int c;
int nword, nother;
nword = nother = 0;
while ((c = getchar()) != EOF)
{
if (c == ' ' ¦¦ '\t' ¦¦ '\n')
++nother;
else
++nword;
}
printf("Words = %d\nOther = %d", nword, nother);
}
I am basically just trying to tell the computer anything that is not a
blank space, a tab , or a newline is a word...
BUT everytime I run the program it adds to only the nother variable.
I can't figure out why, no matter what I type. I thought I had
written this program well and I even sketched it out on paper
beforehand , hehe.
I know you guys will probably find a horribly noobish mistake , but
please remember I started learning C all of like 48 hours ago.