Monday, August 8, 2011

How to Get User Given String to an Array in "C" Language



#include <stdio.h>

int main()
{
char YourText[20];//save the user's string


fputs("Enter your text: ", stdout);
fflush(stdout);
fgets(YourText, sizeof YourText, stdin);

int i;
for(i=0; YourText[i] !='\0'; i++)
printf("%c",YourText[i]);


}//End main

/*

jayangaVliyanage

Jayanga's Blog.........................(http://jayangaliyanage.blogspot.com/)

*/

No comments:

Post a Comment