title: Calling executable file inside C program
body: <p>I have a C program which will take one argument as input and, if the argument is matching with the string inside the executable, it will return 1 otherwise 0. The executable file name is <code>prg1</code>. I have some input strings in a file named <code>inputs.txt</code>. I want to get those strings from the input file and call the <code>prg1</code> inside a C program with each string. </p>
  
  <p>I have tried the following code but it's not working.There is no segmentation fault but when i am calling prg1 it executes, Because the printf() statement inside prg1 is working and i can see the output.it changes variable found to 0I cant change the prg1. Because my friend has given the executable file of that program to me, not the source code. Header files are stdio.h and string.h</p>
  
  <pre><code>int main()
  {
      FILE *fk;
      char text[80],inp[16],test[50]={"./prg1 "};
      int found=100;
      fk=fopen("inputs.txt","r");
      while((fscanf(fk,"%s",inp))!=EOF)
      {
          strcat(test,inp);
          found=system(test);
          if(found==1)
          {
              printf("\nAnswer is   : %s",inp);
              break;
          }
              strcpy(test,"./prg1 ");
  
      }
      fclose(fk);
      return 0;
  }
  </code></pre>
  
  <p>What is wrong with my code?</p>