How would i check for the strings below line by line in a txt and replace each one?
"FLD_CUSTORDREF_FLD"
"FLD_CUSTOMERNAME_FLD"
"FLD_ADDRESSLINE1_FLD"
"FLD_ADDRESSLINE2_FLD"
"FLD_CITY_FLD"
e.g.
If file line has "FLD_CITY_FLD"
change to Header->City
else if file line has "FLD_CUSTOMERNAME_FLD"
change to Header->Name
I can read each line by using
while ( fgets ( line, sizeof line, file ) != NULL )
But how would i check for a matching string?
You’re looking for the
strstrfunction.However the replacing part might be trickier. I would just
fprintfthe result instead of replacing in the string.