Got it working! for real this time
set \t and '' to state OUT
set \n to increment and state out
default if char increment and fixed the word count as another if statement proceeding that.
...
Type: Posts; User: sjmp
Got it working! for real this time
set \t and '' to state OUT
set \n to increment and state out
default if char increment and fixed the word count as another if statement proceeding that.
...
Andreas
I removed c !=4 and it no longer responded to CNTRLD, I am using windows...
I was successful in counting words (ignoring tabs, spaces, newlines)
using:
if(c == '\n' || c == '\t' || c == ' ')
state = OUT;
else if(isalpha(c) && state ==...
Probably making things more of a mess, but trying to get the word count to NOT increment from spaces, new lines, or tabs... tried adding this but still not working
while((c = getchar()) !=...
need to terminate the program using CNTRL D - ASCII 4? that is what I was trying to do there. It works so long as long as I execute CNTRL D on a new line.
Tried to modify but \t still increments word. From my code I can understand why, just dont know exactly how to correct.
switch (c)
{
case ' ':
case...
nonoob - thank you. I tried to condense the code the only problem is that words will increment w/ tab or spaces...
#include <stdio.h>
#include <ctype.h>
#define IN 1
It works now.
It has been slow learning the last few weeks and the fact that you could give me directions and I had the slightest clue to do something with those directions...makes me feel like I...
Thanks - that was helpful - I made the changes - now I get an infinite loop. If I type 'test' - infinite loop w/ Characters 1 (should be four) Lines:0 Words:0 - this happens w and w/o break;
...
I am brand new to programming (2 weeks strong ;)). I have to use a switch statement to output characters, lines and words. I have been using the same if statements for th assignment (while, do-while)...