title: lseek() for copying files
body: <p>what i have done : copying the content of file in reverse order.
  what i am nt able to do : copy the content in the forward direction .</p>
  
  <p>I made research on the web and I found that <code>lseek()</code> has this arguments..</p>
  
  <pre><code>lseek(file_descriptor,offset,whence);
  </code></pre>
  
  <p>for reverse reading the logic is straight forward . And my code is as follows :</p>
  
  <pre><code>#include&lt;fcntl.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  void main(int argc,char *argv[])
  {
      int fd,fd1,count=0;
      char ch='y',buffer;
      if(argc&gt;3)
      {   
          printf("\nSyntax Error!&lt;try&gt; ./cp source_name destination_name\n");
          exit(0);
      }
  
      fd=open(argv[1],O_RDWR);
      if(fd==-1)
      {
          printf("\nCan not open source file .. :(\n");exit(0);
      }
  
      fd1=open(argv[2],O_RDWR);
  
      if(fd1=!-1)
      {
           printf("\nDestination file exist , OverWrite (Y/N) :");
           scanf("%s",&amp;ch);
      }
  
      if(ch=='y'||ch=='Y')
          fd1=creat(argv[2],O_RDWR|0666);
      else
          exit(0);
  
      while(lseek(fd,count,2)!=-1)
      {
          count--;
          read(fd,&amp;buffer,sizeof(char));
          write(fd1,&amp;buffer,sizeof(char));
      }
  }   
  </code></pre>
  
  <p>what changes i thought that could be done for copying the file in forward direction .</p>
  
  <pre><code>count=0;
  
  lseek(fd,count,0)!=-1
  
  
  but this is taking the program in infinite loop . need help .
  </code></pre>