Wow your style unorthodox but it seems to work , why would you would assign a char * for getchar().
Code:
void readline(char line[]) //this function reads the input
{
while((*line=getchar()) != '\n')
line++;
*line= kzerobyte;
}
getchar() prototype is meaning it returns an int which is the character from stdin.
Also if your trying to attach the null character then attach the null character that is as it stands you have
Code:
#define kzerobyte 0
I'm not sure why your code works, but perhaps you were trying to use gets whose prototype is not that its the safest choice.
As it stands you store all your words into a charater array and then expect this to work
Code:
printf("\n%s\n", line);
this will only print out what you have stored in the array and add a newline when its done. If you inist on coding the way you did, you'll have to check for spaces from stdin and put a '\n' whenever there is a space.
Also your use of the <conio.h> is not needed, as it is not portable. You can repalce with .
adding to your style I guess nothing is wrong wit it:
Code:
if(numwords !=1)
printf("s");
why not
Code:
printf("\nthis line has %d %s", numwords, (numwords !=1 ? "words" : "word") );
my two cents
[edit] I guess technically since a char is represented by an integar, a ptr to a char is basically still an int. unorthodox though. interested to see what the other members say[/edit]