title: printing a string using function with variable argument (va_list)
body: <p>i'm trying to print argument variables type string and i've been stuck on this</p>
  
  <h1>The idea</h1>
  
  <p>trying to move inside the srting using <code>_Str[i]</code> as Expression inside a while loop and once <code>_Str[i] == '\0'</code> return (-1) defined as <code>EOF</code>after that we test on <code>'\n' == EOF</code> to return <code>EOF</code>. than switch to the next variable  </p>
  
  <h1>The Code</h1>
  
  <h2>main.c</h2>
  
  <pre><code>int main(int argc, char** argv)
  { 
      ps("test1", "test2");
      return 0;
  } 
  </code></pre>
  
  <h2>base.h</h2>
  
  <pre><code>#ifndef BASE_H_
   #define BASE_H_
    #ifndef EOF // (EOF) - End Of File character. (-1)
     #define EOF (-1)
    #endif// EOF 
   #include&lt;stdio.h&gt;// Facultatif  
   #include&lt;stdarg.h&gt; 
  
      int ps(const char* , ...); // our function
  
  
  #endif // BASE_H_
  </code></pre>
  
  <h2>base.c</h2>
  
  <pre><code>int ps(const char* _Str, ...)
  {
      int  i = 0;
  
      //char* string;
      //va_list
      //
          va_list arg;
          va_start(arg, _Str);
  
      //for(i = 0;    ; ++i)
      //  if(_Str[i] == '\0')
      //      putchar('\n');
      while(1)
      {
          while(_Str[i])
          {
              if( putchar(_Str[i]) == EOF)  //test on EOF value
              { 
                  return EOF;// (-1)
              }//end if
           i++;
          }//end inner while
             if(putchar('\n') == EOF)  //occur right after we quit due to '\0'
             {
                 return EOF;// (-1)
             }//end if
             string = va_arg(arg, char*);
      }//end outter while
  
          va_end(arg); 
          //
          return 1; //to meet spec.
  }// end ps()
  //
  //
  </code></pre>
  
  <h1>Compiling using GCC</h1>
  
  <pre><code>[ar.lnx@host print] $ make
  Building objects..
  gcc -c -o main.o main.c -I. -Wall 
  Building objects..
  gcc -c -o base.o base.c -I. -Wall 
  Building the application core..
  gcc -o x main.o base.o  -I. -g
  Finish.
  [ar.lnx@host print] $ ./x
  Segmentation fault (core dumped)
  [ar.lnx@host print] $ 
  </code></pre>
  
  <p>i'm stuck on this and have no idea of what to do, can anyone help me understand the problem and solve it?</p>