summaryrefslogtreecommitdiff
path: root/README.md
blob: 94fe5b2f9a45be90b5177277a343c37b3fef65a7 (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
45
46
47
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
````

````replaceinfile("input.txt", "output.txt", "%PLACEHOLDER%", "replacement string");````

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