What you should do is take the loop out of main and put it into a function. The purpose of the function is to accept a string then display the individual characters of the string to the screen one at a time.
1. Prompt for and input a string value from the keyboard.
2. Pass this value to a user defined function that will display each character in the string on a separate line of the screen.
3. In main, thank the user for using your program.
The user function will need to:
1. Accept the string as an input parameter. Name this string variable newstring
2. Create a variable named index and initialize it to zero (0)
3. While (newstring[index] does not equal ‘\0’).
i. Display the character at newstring[index] followed by a NL
ii. Increment index
End Loop
4. Return to main.
__________________________________________________
where am i making mistake ???
__________________________________________________
Code:
#include<stdio.h>
int DisplayCharacter(char newstring[]); // Prototype Declaration
int main()
{
char newstring[80];
printf("Enter the String: ");
gets(newstring);
printf("Thank You\n\n\n");
}
//Writing function
int DisplayCharacter(char newstring[])
{
int index = 0;
while(newstring[index] != '\0')
{
printf("%c\n",newstring[index]); // prints the first word of the string
index++;
}
return (index);
}