Thread overview | |||||
---|---|---|---|---|---|
|
November 05, 2008 Many errors while compiling. Please help. | ||||
---|---|---|---|---|
| ||||
#include <iostream> #include <iostream> using namespace std; int main() { int n[5]={1,2,3,4,5}; register int i; ofstream out("test", ios::out | ios::binary); if(!out){ cout << "Not able to open file.\n"; return 1; } out.write((char *) &n, sizeof n); out.close(); for(i=0;i<5;i++)// clearing array n[i]=0; ifstream in("test", ios::in | ios::binary); if(!in) { cout <<"Not able to open file. \n"; return 1; } in.read((char *) &n, sizeof n); for(i=0;i<5;i++)// showing value, which are rode from file. cout << n[i] << " "; in.close(); return 0; |
November 05, 2008 Re: Many errors while compiling. Please help. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Artur | Artur skrev: > #include <iostream> > #include <iostream> The second one should be: #include <fstream> > return 0; I miss a } here With the above changes, it should compile, if not, tell us what the compiler tells you. |
November 06, 2008 Re: Many errors while compiling. Please help. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bertel Brander | I tried so hard but I must have been blind... It works! Thanks. |
Copyright © 1999-2021 by the D Language Foundation