fwrite() equivalent ?

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

using .NET classes, how can you write a 'myobject' to a file with one
command, as in C :

struct MyStruct
{
char m_name[20];
int m_age;
} myS;
myS.m_age = 20;
strcpy(myS.m_name, "Bob");

FILE* fp = fopen("test.txt", "w");
fwrite(&myS, sizeof(struct MyStruct), 1, fp); --> WRITE IN ONE GO

thnx

Chris
 
Have a look at the BufferedStream and the MemoryStream classes
Also, if you want to use fwrite(), then use it. When you get comfortable with the managed extensions, you can replace the C read/write methods.
 
Back
Top