Friday, July 31, 2009

How do i make a program that will display a selected string in c language?

ex: if i input " hello"


the output would the first the the letters like "hel"

How do i make a program that will display a selected string in c language?
#include %26lt;stdio.h%26gt;





int main()


{


char input[4];


printf("Please enter a word: ");


fgets(input, 4, stdin);


printf("\nFirst 3 characters of input: %s", input);


getchar();


return 0;


}








Enjoy!


No comments:

Post a Comment