0

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.

4
  • This requires C++11 support. Have you compiled with that switched on? Commented May 26, 2013 at 15:01
  • @juanchopanza i'm using vc6 Commented May 26, 2013 at 15:05
  • Then I doubt you have any C++11 support. Commented May 26, 2013 at 15:15
  • @juanchopanza juanchopanza is your name?? it seems like a chinese pronunciation. Commented May 26, 2013 at 15:19

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.