Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX_LEN_SINGLE_LINE 150
- void main(char argc[6])
- {
- printf("Version is %s\n", version);
- const char fileOrig[32] = "work.xml";
- const char fileRepl[32] = "work.xml";
- const char text2find[80] = "<Version>000000</Version>";
- const char text2repl[80] = "<Version>000001</Version>";
- char buffer[MAX_LEN_SINGLE_LINE+2];
- char *buff_ptr, *find_ptr;
- FILE *fp1, *fp2;
- size_t find_len = strlen(text2find);
- fp1 = fopen(fileOrig,"r");
- fp2 = fopen(fileRepl,"w");
- while(fgets(buffer,MAX_LEN_SINGLE_LINE+2,fp1))
- {
- buff_ptr = buffer;
- while ((find_ptr = strstr(buff_ptr,text2find)))
- {
- while(buff_ptr < find_ptr)
- fputc((int)*buff_ptr++,fp2);
- fputs(text2repl,fp2);
- buff_ptr += find_len;
- }
- fputs(buff_ptr,fp2);
- }
- fclose(fp2);
- fclose(fp1);
- printf("Done!\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment