Sh3ll
OdayForums


Server : Apache
System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64
User : apache ( 48)
PHP Version : 8.0.28
Disable Function : NONE
Directory :  /var/www/html/mmishra/nweb/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/mmishra/nweb/find-replace-string.c
#include <stdio.h>
#include <string.h>
 
int main ( ) {
    char buff[BUFSIZ];      // the input line
    char newbuff[BUFSIZ];   // the results of any editing
    char findme[] = "hello";
    char replacewith[] = "world";
    FILE *in, *out;
 
    in = fopen( "file.txt", "r" );
    out= fopen( "new.txt", "w" );
 
    while ( fgets( buff, BUFSIZ, in ) != NULL ) {
        if ( strstr( buff, findme ) != NULL ) {
            // do 1 or more replacements
            // the result should be placed in newbuff
            // just watch you dont overflow newbuff...
        } else {
            // nothing to do - the input line is the output line
            strcpy( newbuff, buff );
        }
        fputs( newbuff, out );
    }
 
    fclose( in );
    fclose( out );
    return 0;
}

ZeroDay Forums Mini