Thread: memcpy

  1. #16
    Registered User
    Join Date
    Sep 2011
    Posts
    8
    yep, thats exacly what I mean. been searching for answer for like 3 days now.

  2. #17
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by sharp_wan View Post
    yep, thats exacly what I mean. been searching for answer for like 3 days now.
    Ummm... did you try looking in your textbooks and library documentation? Really opening a file is pretty basic stuff usually covered in some depth in any good tutorial or textbook. The library docs for your compiler should have fleshed out the details for you....

    You probably should sit down with a textbook or good tutorial (from the web) and work it page by page, example by example, as a deliberate study... I'm betting you'll be glad you did.
    Last edited by CommonTater; 10-03-2011 at 03:45 PM.

  3. #18
    Registered User
    Join Date
    Aug 2010
    Posts
    231
    Code:
    FILE* pFile=fopen("yourfilename","rb");
    long lSize=your_work_getfilesizefrom(pFile); 
    char * buffer=malloc(lSize);
    
    if( fread( buffer , lSize, 1, pFile ) )
      puts("OK");
    else
      perror("yourfilename");

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    your_work_getfilesizefrom(pFile); ???

    If you say so....

  5. #20
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    You can seek to the end of the file to get the file size if you don't want to use an OS function like stat() for example. But in this case the easiest thing to do is probably a blocking fgetc/fputc loop one character at a time, simple (but slow).

    Code:
    int tmp;
    
    while( (tmp = fgetc(infile)) != EOF ) {
         fputc(tmp, outfile);
    }
    Last edited by Subsonics; 10-03-2011 at 04:21 PM. Reason: Messed up the order in fputc

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memcpy not doing its job
    By Hawkin in forum C Programming
    Replies: 4
    Last Post: 11-11-2010, 12:17 PM
  2. using memcpy?
    By nyekknyakk in forum C Programming
    Replies: 1
    Last Post: 08-19-2010, 07:47 PM
  3. memcpy
    By m37h0d in forum C++ Programming
    Replies: 28
    Last Post: 04-12-2008, 09:10 PM
  4. memcpy()
    By Moni in forum C++ Programming
    Replies: 3
    Last Post: 09-05-2006, 05:31 AM
  5. Help: About memcpy()
    By naruto in forum C Programming
    Replies: 41
    Last Post: 06-25-2004, 03:47 PM