blob: c52204b6526951e2f6c9b7272cb4253f351b85ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
Convenience function to replace every occurance of a string in a file with a replacement string, outputs to another file.
Compile with ````make```` and run with ````./example````.
definition in replace.h:
````
int replaceinfile(char *originalfile, char *destinationfile, char *placeholder, char *replacement);
// 0 = failure, 1 = success
````
input.txt
````
Normal text file
%PLACEHOLDER%
%PLACEHOLDER%
%PLACEHOLDER%
With lines and whatever, %PLACEHOLDER%
123%PLACEHOLDER%123
ok %PLACEHOLDER% ok
````
output.txt
````
Normal text file
replacement string
replacement string
replacement string
With lines and whatever, replacement string
123replacement string123
ok replacement string ok
````
See main.c for a usage example
|