String Input
Title
Question
#include<stdio.h>
void main()
{
<span style="white-space:pre">\t</span>char a;
<span style="white-space:pre">\t</span>char s[10],s1[10];
<span style="white-space:pre">\t</span>printf("Enter String: ");
<span style="white-space:pre">\t</span>scanf("%[^\\n]s",s1);
<span style="white-space:pre">\t</span>printf("Enter string2: ");
<span style="white-space:pre">\t</span>scanf("%[^\\n]s",s);
<span style="white-space:pre">\t</span>printf("String1: %s\\n",s1);
<span style="white-space:pre">\t</span>printf("String2: %s",s);
<span style="white-space:pre">\t</span>}
Output:
Enter String: Himani
Enter string2: String1: Himani
String2: @
I am not able to read values in second string.
C-and-Cpp Strings 05-06 min 10-20 sec
Answers:
Please write your code in a text editor like notepad. It looks like you have written it in word or some such editor, due to which one cannot read the code above very clearly.
Login to add comment