Hey all im new to the site and looking around i can tell i came to the rite place. Now for my question.
Im suppose to take a poem with punctuations and blank lines in it and reprint the poem one word per line. The reprint cant have punctuations or blank lines in it. I was able to do that so far, but the program does not recognize capital letters and I really dont know how to get it to print one whole word per line. Also I cant use any string handling functions in my code only getchar and putchar. So hopefully what i have writing down so far is still useable.
Here is a copy of my code for far:
#include <ctype.h>
#include <stdio.h>
#define _CRT_SECURE_NO_DEPRECATE
/*Function prototype*/
char NewPoem (char);
int main ()
{
char iochar;
printf("Enter the poem for format conversion.\n");
scanf("%c", &iochar);
printf("\nYou're new poem : %c\n", iochar);
/*Call the function*/
NewPoem (iochar);
}
/*Function to handle poem*/
char NewPoem (char iochar)
{
while ( ( iochar = getchar() ) != EOF )
{
if ( ( 'A' <= iochar ) && ( 'Z' <= iochar) )
{
putchar (iochar);
}
else if ( ( 'a' <= iochar ) && ( 'z' <= iochar ) )
{
putchar (iochar);
}
}
}
I have tried to make another function to get the program to read the length of the word, but im not sure if it was even correct in anyway since the program just kept printing the output as if it was just the code I printed above.
what I want to know is:
1) What do I need in a function to take a whole word?
2) How do I print each word in a new line?