Like Tree2Likes
  • 2 Post By Salem

How can I move data from 1 file to another without pointers.

This is a discussion on How can I move data from 1 file to another without pointers. within the C Programming forums, part of the General Programming Boards category; Hi, How can I move data from one file to the another file without using pointers. Plz give some code. ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    54

    How can I move data from 1 file to another without pointers.

    Hi,

    How can I move data from one file to the another file without using pointers. Plz give some code. Thnx

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    One character at a time.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    1,063
    Here is some code

    Code:
    c = fgetc(fp1);
    fputc(c, fp2);

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,261
    In that example, c99tutorial, both fp1 and fp2 would be pointers.....
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,063
    True. Okay, let's simplify to

    Code:
    c = getchar();
    putchar(c);
    Then it is your responsibility to call the program like this

    Code:
    copybytes < file1 > file2

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    complete program plz................?

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    If you can't put int main() around either of c99tutorial's posts after a whole day, then you should probably give up programming as a career choice.
    DeadPlanet and AndiPersti like this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    Moving data from one file to another can be accomplished easily with rename. Unfortunately, that accepts two pointers to const-qualified char, which doesn't seem to satisfy your criteria. That doesn't really matter anyway, because your requirement of using 'no pointers' is difficult and impossible from a few perspectives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Move to specified line in CSV file
    By strokebow in forum C++ Programming
    Replies: 26
    Last Post: 07-03-2012, 09:35 AM
  2. Inputting Data File Using Pointers
    By jl864405 in forum C Programming
    Replies: 8
    Last Post: 06-04-2009, 05:52 PM
  3. How do you move around a text file in C?
    By buggerboy_3 in forum C Programming
    Replies: 9
    Last Post: 04-29-2007, 06:39 PM
  4. Move file during shutdown
    By mdoland in forum Windows Programming
    Replies: 2
    Last Post: 11-08-2005, 12:34 AM
  5. writing data to a file from an array of pointers
    By Mingzhi in forum C++ Programming
    Replies: 1
    Last Post: 07-19-2004, 09:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21