saving . . . saved String Input has been deleted. String Input has been hidden .
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 29-02-20, 3:36 p.m. Himani.Parekh

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.
29-02-20, 4:23 p.m. bhaskar76


use this:   "%[^\\n]%*c"  instead of  "%[^\\\\n]s" the problem is solved

29-02-20, 4:27 p.m. SudheerSharma


Log-in to answer to this question.