Why std::fstream::write() modifies tellg()?
Executing the following code
invoke destructor manually
int x; // ok, done with it // how do I destroy var. x manually? // then reuse name float x; How do I destroy variables manually and use same var. name in same scope? My actual situation look more like this: std::ofstream output; // do stuff output.close(); // at this point I need to […]
My Program Fstream Function Crashes The Program
Im a beginner trying to load the contents of list_goods.txt to the products struct but the prodload() function crashes the program even tough it compiles, what am i doing wrong?
writing double** matrix to a binary file?
I have a 2d array matrix defined as double** map. The size is num_columns * num_rows.
How can I use fstream to copy the data to a binary file? can it be done at once?
Opening file with fstream
I have written a class for handling text files and it looks like this.
data size always 1kb although the program always got writing add new data to my file everytime
int get_datasize(std::fstream& data) { int start; int end; data.seekg(0, std::ios::beg); start = data.tellg(); //sizeof start is output 0 data.seekg(0, std::ios::end); end = data.tellg(); // sizeof end is output 4 return ((end – start) / sizeof(Student) ); // sizeof student is output 128 } The resulting always got 0 for got data size, for more information […]
C++ append to file
int main(){ fstream plik; plik.open(“dane.txt”, ios::out); plik << “Aaaaan”; plik << “Aaaaa”; plik.close(); plik.open(“dane.txt”, ios::in); while(!plik.eof()){ string linia; plik >> linia; cout << linia << ” “; } plik.close(); plik.open(“dane.txt”, ios::out); plik << “Baaaa”; } i wanted to add text to an already created file, dunno why but append isnt working or im doing smth […]