Hello
I need a static string array in my program for instance:
Is there any better/other way to do this in c++, or I have to do it the same as in c?Code:char *day[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
Hello
I need a static string array in my program for instance:
Is there any better/other way to do this in c++, or I have to do it the same as in c?Code:char *day[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
... or depending on how it's usedCode:#include <string> std::string days[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};... but of course that option also works in C, as well.Code:enum days { SUN, MON, TUE, WED, THU, FRI, SAT };
Sent from my iPadŽ
Or:
I am not sure \0's are needed but I added them so there can be no problem with the code.Code:char day[7][4]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
Last edited by maxorator; 10-08-2006 at 07:03 AM.
"The Internet treats censorship as damage and routes around it." - John Gilmore
They're not needed. On the contrary, you just created compile-time buffer overflows, and a good compiler would refuse to compile it.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law