Thread: need help with my function

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    16

    need help with my function

    I'm trying to make a function scan a file for a string and replace part of the string.I've got it to scan the file and detect the string but replaceing the part of the string is a problem.I'm trying to make it turn 0200 0424 into 0100 0424.Here the code I've done:
    Code:
    int replace_str(FILE *x)
    {
    int *cp[8];
    int i=0;
    int c;
    fseek(x,0,SEEK_SET);
    while( (c = fgetc( x )) != EOF )
    {
    if ( c == 0x01 ) { cp[i]=&c;
    if ( c == 0x00 ) { cp[i]=&c;
    if ( c == 0x04 ) { cp[i]=&c;
    if ( c == 0x24 ) { cp[i]=&c;
    if ( c == 0x02 ) { cp[i]=&c;
    if ( c == 0x00 ) { cp[i]=&c;
    if ( c == 0x04 ) { cp[i]=&c;
    if ( c == 0x24 ) { cp[5]=0x01 ; i++;}
    }}}}}}}
    
    }
    
    return 0;
    }
    Last edited by angelfly; 10-15-2001 at 12:48 PM.

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Use the ability of random file access: This involves the function, fread, fseek, and fwrite.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM