title: scanf fails to read a string in C
body: <p>I have a simple C program as follows:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
    char a[100],b[100];
    char *ret;
    printf("Enter the string\n");
    scanf("%s",a);
    printf("Enter the substring to be searched\n");
    scanf("%s",b);
    ret= strstr(a,b);
    if(ret==NULL)
    {
      printf("Substring not found\n");
    }
    else
    {
      printf("Substring found \n");
    }
  }
  </code></pre>
  
  <p>When I execute the following program, scanf to read the string into b is not waiting for me to enter the substring and the print statement that prints the <code>substring not found</code> is being printed on the console. I tried to give <code>%s</code>and tried in the scanf statement and removed <code>\n</code> from the printf statements and nothing changed the way it executed the program. It would be great if someone solves this simple problem. Thanks in advance.</p>