everyone I'm a student totally a noob in this of programming just know a litle web programming JS-HTML5, but nothing extraordinary.
I need help with some problems. Thanks if you help, and thanks if not. :D
*. Make a program in C++ that read a text file name: NUMBERS.txt, that file contains any number in each line. teh program haves to reed every number, print it in screen and detect and print too if it's pair or not pair.
*. Another program in C++ that generates N wholes number randomly and stores it in a binary file name: wholes.dat. I aske somebody about this and he told me: "You might consider giving rand a look, it would help you to generate random numbers. You can set the limit to start from zero to (a limit). Whole numbers start from zero and go to... Infinity."; but i really don't get how to code it...
#include <fstream>
#include <iostream>
using namespace std;
int main(void){
double num(123.456), x; //
fstream escr_leer("arch4.bin", ios::out | ios::in | ios::binary);
if( escr_leer ){
escr_leer.write((char*)(&num), sizeof(num));
escr_leer.seekg(ios::beg);
escr_leer.read( (char*)(&x), sizeof(x));
cout << x << endl;
}
else{
cout << "\nERROR ABRIENDO EL ARCHIVO DE TEXTO\n";
exit(1);
}
escr_leer.close();
return 0;
}
This code was sperimenting with fstrea; but's not working. Help!! Thanks for your time.