Reputation: 2332
i.m using vc6, i made a struct like this:
struct FileInfo
{
char filename[200] = {0};
char ext[20] = {0};
int f_size=0;
int offset=0;
char* pData=0;
};
but I got a error C2059: syntax error : '{'
error,
and i dont know how to initialize arrays inside correctly.
Upvotes: 0
Views: 361
Reputation: 409176
You initialize the members when you create an instance of this structure. In C++ this is done in the constructor while in C it's done like:
struct FileInfo my_file_info = { { 0 }, { 0 }, 0, 0, 0 };
The C way can of course be used in C++ too, if you don't want to add a constructor (for example if the structure is shared between a C and a C++ program).
Upvotes: 4