basic code for dev c++ windows.

i want to use a program that outputs data to a text file name output.txt
---
1) the file name output.txt contain alfanumaric data. like 12T13 and 31T21.
2) load a file 12T13 or 31T21 output.txt will decide, data in files is numaric data from 100 to 9999999.
3) and if data in that file is not less then 1 devalue (--) its value in every 1 seconds. otherwise start from beginning again until the file value/data reaches to less then 1 or (kill switch is pressed)
5) if the kill switch is pressed or files value/data <1 save the file value/data and start the program again.
---
any clue how do i do it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(int argc, char** argv) { //auto set by dev c++ in windows.
	ifstream myfile;
	string DF;
	myfile.open ( "output.txt" ); //open "output.txt" file 
	myfile >> DF ;			//and load its data to DF.
	cout << DF ;		// DF is shown on screen. witch is 12T13
	myfile.close() ;

	//DF.open (  ); //the data inside "output.txt" is another file name.
	// witch is alfanumaric data "12T13" now i want to load file name "12T13" and use its data the data inside
	//file name "12T13" is numaric data "100" this will be decreased in ever 1 sec.

	cout << "\n"; //new line betwen data and pause.
	cout << "Press Enter to continue..." << endl; //pause result on screen untill user press enter key.
cin.ignore(10, '\n');
cin.get();
	return 0;
}
Last edited on
thanks the problem is solved by (nameOfFile.c_str() );
(nameOfFile.c_str() );
This c_str() may be required if using an older compiler - or your current set-up is configured to use an old default setting.

Try adding -std=c++11 to the compiler options.
Last edited on
Topic archived. No new replies allowed.