title: how to use strstr()?
body: <p>i want to take data from file and store it in string array and and perform a search function with only few information like type"j" and the program able to look for data name which contain "j".
  but my program cannot work.....
  i am wondering am i using the strstr() correctly or not?</p>
  
  <p>my text file :</p>
  
  <pre><code>Jason Derulo
  5000
  Martin Delux
  8752
  Justin Haber
  51855
  Alex Zander
  52163
  </code></pre>
  
  <p>and </p>
  
  <p>coding:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  //---------------------------------------------------------------------------------------------------------
  typedef struct
  {
  
      char name[30],adv_srh_name[30];
      double balance;
  
  }ACCOUNT;
  
  
  int main()
  {
      ACCOUNT record[31]; 
      int choice,acc_amount=0;
  
      ifstream openfile("list.txt");              //open text file 
      if (!openfile)
      {
          cout &lt;&lt; "Error opening input file\n";
          return 0;
      }
  
      else
      {
          ACCOUNT temp;
          int i = 0;
          double d = 0;
  
          while (openfile)
          {
              openfile.getline(temp.name, 30, '\n');
  
              //consume the newline still in the stream:    
              if ((openfile &gt;&gt; d).get()) { temp.balance = d; }
  
              record[i] = temp;
              i++;
          }
          openfile.close();               //close text file
          acc_amount = i;
      }
  
      cout &lt;&lt; "Please enter a client name:";
          fflush(stdin);
          cin.getline(adv_srh_name, 30);
  
          for (int j = 0; adv_srh_name[j] != NULL; j++)
              adv_srh_name[j] = toupper(adv_srh_name[j]);
  
          cout &lt;&lt; adv_srh_name;
  
          for (int a = 0; a &lt; acc_amount; a++)
          {
              if ((strstr(record[a].name, adv_srh_name)) != NULL)
              {
                  cout &lt;&lt; "Name :" &lt;&lt; record[a].name &lt;&lt; "\n";
                  cout &lt;&lt; "Balance :" &lt;&lt; record[a].balance &lt;&lt; "\n\n";
              }
  
          }
          return 0;
      }
  </code></pre>