strings 2
//different methods to take a string from user
#include <stdio.h>
int main()
{
char str1[10];
printf("enter a string:");
gets(str1); //method 1: using gets function
printf("%s\n",str1);
char str2[10];
printf("enter a string:");
scanf("%s",&str2);//method 2:using scanf, but with this we cannot use white spaces in string
printf("%s\n",str2);
printf("using puts displaying string output\n");
puts(str2);//puts function is used to display string output
return 0;
}
Comments
Post a Comment