golferadam
Technical User
I am new so let me begin by thanking in advance anyone that can help me.
I have a simple program that uses data files (contains integers and characters). I want to allow the user to modify the files (i.e. add new ID#s and ID Names). Here is an example of the input file:
5
1 ETHANE C2H6
2 PROPANE C3H8
3 ISOBUTANE C4H10
4 n-PENTANE C5H12
5 n-HEXANE C6H14
As you can see, the integer at the top (5) is the total number of ID#s in the input file. The first thing my code does is read that number. The new data will be assigned to the next higher integer (in this case, 6).
I need to advance to the end of the file and then write the new data. An example would be to advance to the 5th entry, and add a new line of data at the end:
5 n-HEXANE C6H14
6 TOLUENE C7H8 <--- New line
Then I want to update the number at the beginning of the file (in this case 5) and save the file over the old one.
Thanks.
I have a simple program that uses data files (contains integers and characters). I want to allow the user to modify the files (i.e. add new ID#s and ID Names). Here is an example of the input file:
5
1 ETHANE C2H6
2 PROPANE C3H8
3 ISOBUTANE C4H10
4 n-PENTANE C5H12
5 n-HEXANE C6H14
As you can see, the integer at the top (5) is the total number of ID#s in the input file. The first thing my code does is read that number. The new data will be assigned to the next higher integer (in this case, 6).
I need to advance to the end of the file and then write the new data. An example would be to advance to the 5th entry, and add a new line of data at the end:
5 n-HEXANE C6H14
6 TOLUENE C7H8 <--- New line
Then I want to update the number at the beginning of the file (in this case 5) and save the file over the old one.
Thanks.