title: Execv with argument array
body: <p>I have a simple C program that creates an array of arguments as required by the second argument of <code>execv()</code> that executes a program that computes and outputs the Caeser Cipher decoding of the argument. However the file calling <code>execv()</code> seems to ignore the call and moves ahead. What should I do?</p>
  <p><strong>The code</strong></p>
  <p>execv-test-arg.c:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int main (void)
  {
          char *argv[3];
          argv[0] = &quot;caesar-cipher&quot;;
          argv[1] = &quot;SDQGD&quot;;
          argv[2] = &quot;\0&quot;;
          execv(&quot;caesar-cipher&quot;,argv);
          printf(&quot;Returned from execv call.\n&quot;); // This is what is being printed
          return 0;
  }
  </code></pre>
  <p>caesar-cipher.c</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  int main (int argc, char *argv[])
  {
     int i, j;
  
     for (i=1; i&lt;argc; i++) {
        j=0;
        while (argv[i][j] != '\0') {
           if ((argv[i][j] &gt;= 'A') &amp;&amp; (argv[i][j] &lt;= 'Z')) {
              printf (&quot;%c&quot;, 'A'+(argv[i][j]-'A'+23)%26); // To be printed
           }
           else if ((argv[i][j] &gt;= 'a') &amp;&amp; (argv[i][j] &lt;= 'z')) {
              printf (&quot;%c&quot;, 'A'+(argv[i][j]-'a'+23)%26);
           }
           else if ((argv[i][j] &gt;= '0') &amp;&amp; (argv[i][j] &lt;= '9')) {
              printf (&quot;%c&quot;, '0'+(argv[i][j]-'0'+7)%10);
           }
           else printf (&quot;Invalid input.\n&quot;);
           j++;
        }
        printf(&quot; &quot;);
     }
     printf(&quot;\n&quot;);
     return 0;
  }
  
  </code></pre>
  <p>Required output:</p>
  <pre><code>PANDA
  </code></pre>
  <p>Current output:</p>
  <pre><code>Returned from execv call.
  </code></pre>