Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with reading text files

Status
Not open for further replies.

Dule2111

Programmer
Jan 12, 2008
1
0
0
YU
hello,
basicly my problem is how to read text file that contains chars and real numbers witch i need to modify, and not to change any other char in it;
i have to make a procedure that changes degrees that are shown in F and convert them in C;
input file should look like this:
"today's the temperature should be 15C and tomorrow 56.2F"
and the output file like this:
"today's the temperature should be 15C and tomorrow 13.44C"
something like that
plz help me
 
The text file is best thought of as a packed array of characters. Thus, if you replace a number with another number that has a different number of digits then every character following that number is changed.

The simplest way to do it would be to create a loop that reads each line of the file, searches and replaces the text of interest (your numbers), and writes the modified line to a new file. After doing this for all lines in the file, delete the original file and rename the new file to the original file's name.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top