hi,
Can anyone tel me how to Save and Load data to and from .txt or binary files in C++?
hi,
Can anyone tel me how to Save and Load data to and from .txt or binary files in C++?
Last edited by IndioDoido; 10-15-2007 at 06:35 PM. Reason: I/O Binary Files in C++
"Artificial Intelligence usually beats natural stupidity."
GIYF.
Or even this could get you started (although it seems like a poor example).
hey MacGyver, thanks!
i checked the example...i think it will do for now :-)
By the way... GIYF ?!?!?!
"Artificial Intelligence usually beats natural stupidity."
JFGI.By the way... GIYF ?!?!?!
Yeah, STFW.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
And don't forget to RTFM while you're at it.
what the helll !?!?!?!
i'm lost here :-(
by the way...
i'm getting this error:
Expression: vector subscript out of range
how can i resolve this?
Last edited by IndioDoido; 10-16-2007 at 06:44 PM. Reason: New Question :-D
"Artificial Intelligence usually beats natural stupidity."
"Stop using a subscript out of the vector's range?"
how?
the error starts here:
Code:if(dadosProp.empty() == false) //-> ERROR { for(int i=0; dadosProp.size(); i++) { if(dadosV.getNumBiProp() == dadosProp[i].getBI() ) dadosVeiculo.push_back(dadosV); else { cout<<"Proprietario não existe! Insira um novo..."; system("pause"); system("cls"); preencheProprietario(dadosP); inserirProp(dadosP); } } } else etc..etc...
"Artificial Intelligence usually beats natural stupidity."
Code:int array[9]; // you now have an array of 9 int's array[9] = 5; // You can't do this as you are out of the array's range // You only have 0-8, so if you call -1 and beyond or 9 and beyond you // are trying to access memory that the array does not have allocated. // Thus you get subscript out of range error, same with vectors
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.
but where in the code am i subscripting?
must i use the reserve() function to resolve this?Code:if(dadosProp.empty() == false) { for(int i=0; dadosProp.size(); i++) { if(dadosV.getNumBiProp() == dadosProp[i].getBI() ) dadosVeiculo.push_back(dadosV); else { cout<<"Proprietario não existe! Insira um novo..."; system("pause"); system("cls"); preencheProprietario(dadosP); inserirProp(dadosP); } } } else { cout<<"\nInsira o novo proprietario...\n"; system("pause"); preencheProprietario(dadosP); inserirProp(dadosP); dadosVeiculo.push_back(dadosV); }
"Artificial Intelligence usually beats natural stupidity."
"Artificial Intelligence usually beats natural stupidity."
So true...so true.
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.
sorry...
i've figured it out
used:
thanks for the help guys :-)Code:dadosProp.reserve(50); dadosVeiculo.reserve(50); if(dadosProp.empty() == false) { for(int i=0; i>=50; i++)
"Artificial Intelligence usually beats natural stupidity."