is this code valid?
where intA is 0 - will this create a new structure called newStruct1?
Code:struct appA newStruct[intA + 1];
is this code valid?
where intA is 0 - will this create a new structure called newStruct1?
Code:struct appA newStruct[intA + 1];
If intA is a constant, then it's valid to do that. It will not so much "create a new struct" as make an array with one element of such structs - that may well be what you meant, but creating a new struct [in the way I'd use those words] means to create a different struct, not create an instance of an existing struct.
If intA is not a constant, then you are relying on compiler extensions to achieve this, and it's not standard compliant. If the compiler accepts it, and intA has a defined value at the point where this code occurs, it will work, but it won't necessarily compile with a different compiler.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
It's valid in C99 constant or not, it will create an array with intA + 1 elements called newStruct. Not a variable called newStruct1
Thanks for the replies. More to the point, see my latest post...