0

my struct is defined like this:

typedef struct
{
  int foo;
  char key;
} myStruct;

and I would like to change it to

using struct myStruct = {
      int foo;
      char key;
    } myStruct;

but it seems that something is wrong with it

Alex Butane
  • 127
  • 8

1 Answers1

3

Yes, you can replace

typedef struct
{
  int foo;
  char key;
} myStruct;

by

using myStruct = struct
{
  int foo;
  char key;
};

But it doesn't make any sense, and you will just confuse readers or possible maintainers of the code.

The established way to go is:

struct myStruct
{
  int foo;
  char key;
};
Daniel Langr
  • 22,196
  • 3
  • 50
  • 93