If I have class [5][20], how would I initialize it to have Boss, Manager, sales, ect on class[0][], class[1][] ..... respectively.
This is a discussion on initializing 2d strings within the C Programming forums, part of the General Programming Boards category; If I have class [5][20], how would I initialize it to have Boss, Manager, sales, ect on class[0][], class[1][] ..... ...
If I have class [5][20], how would I initialize it to have Boss, Manager, sales, ect on class[0][], class[1][] ..... respectively.
If you write and post some code, we can help guide you through whatever problems you are seeing.
--
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.
Word Sort
On that post I have done the input thing correctly, sorting function is bad.
Oh sorry, yes it is a character array, class is just the name of it.
From your example, it looks like a user input, I want to go ahead and initialize the string to 5 different words.
char class[5][20]={ }. What goes in the brackets?
Last edited by Fox101; 02-05-2008 at 07:52 AM.
I am a beginner. I don't know what goes into the brackets. That's why I used a temp string and loops to access each element and put the characters in them
I found what you are looking for:
http://www.learncpp.com/cpp-tutorial...sional-arrays/
Last edited by abh!shek; 02-05-2008 at 08:37 AM.
The syntax would be:
Code:char class[5][20] = { "String1", "String2", etc };
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^