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

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

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

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

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

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.
    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.

  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, 01: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