S
Stuart Norris
Dear Readers,
I am attempting to initialise a struct contiaing a dynamic character
string. In the example below I am trying to initialise the name field
so that my struct does not waste space. I know if I change char
name[80] this will work, but I will waste alot of space. (I am
learning so I want to learn the best way)
How can I define a struct the allows variable length character strings
in the
definition?
Thank
Stuart
#include <stdio>
#include <stdlib>
int main (int argc, char **argv)
{
struct command
{
unsigned int cmd;
unsigned int olen;
unsigned int ilen;
char name[];
} init[] = {{0,0,0,"Name A"},{0,0,0,"Name B 123"}};
}
I am attempting to initialise a struct contiaing a dynamic character
string. In the example below I am trying to initialise the name field
so that my struct does not waste space. I know if I change char
name[80] this will work, but I will waste alot of space. (I am
learning so I want to learn the best way)
How can I define a struct the allows variable length character strings
in the
definition?
Thank
Stuart
#include <stdio>
#include <stdlib>
int main (int argc, char **argv)
{
struct command
{
unsigned int cmd;
unsigned int olen;
unsigned int ilen;
char name[];
} init[] = {{0,0,0,"Name A"},{0,0,0,"Name B 123"}};
}