Sorry if this is solvable via Google -- I couldn't find anything.
char foo[4] = "abcd";
is invalid in C++ (due to the need for '\0' terminator) but IIRC valid in C -- is that correct?
I have a set of structs with a large number of "fixed length" character fields that are to be blank-padded and not '\0' terminated. I would like to be able to do the usual sort of struct initialization -- you know
mystruct bar = {17, "abcd", 0x18, "widget ", ...
But I can't do that in C++. One solution I guess would be to put all of the initialized structs like this into their own C (not ++) source module. The ugly, laborious solution that I am trying to avoid is
mystruct bar = {17, {'a', 'b', 'c', 'd'}, 0x18, {'w', 'i', 'd', 'g', 'e', 't', ' ', ' '}, ...
Is there a good C++ solution? A clever macro that will effectively let "abcd" be char[4] with no '\0' terminator?
Thanks, Charles