writing to the disk file incase of database devt.
My name is Antonio from Kampala, a Computer Science student at Kyambogo University. I'm so happy about this opportunity to the get on to first this online discussion/help by WROX.
I'm trying to design a database in C++/C using Classes and Objects,i'm using the book Beginning C++ by IVOR HORTON.
I kindly beg to find out why when i enter the data in my output, in textmode, the file is created,but when i go to view the data, the file is empty?
Please have a look at the code i use to write below;
if((fp=fopen("temp.txt","wt+"))==NULL)
{ fprintf("\n Unable to open file for input");
fclose(fp);
}
if((fp=fopen("temp.txt","wt+")==0)
{ for(int i=0;i<entries;i++)
{
fwrite((char*)&entries[i],sizeof(Employee));
}
fclose(fp);
}
where *fp is the FILE STRUCTURE,Employee is the object,entries are the number of entries made.
Secondly, why is it C++ doesn't capture color using 'cout', i've to use cprintf instead?
Please help me!!
|