Click here to Skip to main content
15,902,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help me to decipher the error messages Pin
Dave Kreskowiak20-Jan-24 4:56
mveDave Kreskowiak20-Jan-24 4:56 
AnswerRe: Help me to decipher the error messages Pin
Gerry Schmitz20-Jan-24 6:34
mveGerry Schmitz20-Jan-24 6:34 
AnswerRe: Help me to decipher the error messages Pin
Richard Andrew x6421-Jan-24 11:33
professionalRichard Andrew x6421-Jan-24 11:33 
AnswerRe: Help me to decipher the error messages Pin
CPallini21-Jan-24 20:33
mveCPallini21-Jan-24 20:33 
AnswerRe: Help me to decipher the error messages Pin
jschell22-Jan-24 5:24
jschell22-Jan-24 5:24 
GeneralRe: Help me to decipher the error messages Pin
Richard MacCutchan22-Jan-24 6:22
mveRichard MacCutchan22-Jan-24 6:22 
GeneralRe: Help me to decipher the error messages Pin
Gerry Schmitz26-Jan-24 6:13
mveGerry Schmitz26-Jan-24 6:13 
QuestionLoop thru two dimensional array - edited Pin
Salvatore Terress15-Jan-24 7:41
Salvatore Terress15-Jan-24 7:41 
Minor add:

I think the loop increment is wrong

I have commented out inner loop and addend two more list to the array
so the decimal count should be 5.
OK the code say Array size 4
and it misses the last array.
That should be a snap to fix...

<"TASK #ifdef FUNCTION_TEST_PROJECT int MainWindow_Bluetooth::CreateMenus_Array()79"
" index array 0  Array size 4"
" index array 1  Array size 4"
" index array 2  Array size 4"
" index array 3  Array size 4"/pre>








OK, I have plain C question about nested  "loop" 

My task is to loop thru two dimensional array...
The error in my code is stopping the embedded loop.

Here is a snippet of the run debug messages

here is the "problem " code 

 for (index_main = 0; index_main < list_array[index_array][index_main].size(); ++index_main)
What am I doing wrong in sizing the array?
Many thanks for help resolving this.

Debug


 <pre lang="text">" index array 0Array size 4"
" main menus  0 SubWindow terminal     (QMdiArea )main menu size 34"
" main menus  1 SubWindow hcitool      (QMdiArea )main menu size 34"
" main menus  2 SubWindow bluetoothctl (QMdiArea )main menu size 34"
" main menus  3 SubWindow system       (QMdiArea )main menu size 34"
ASSERT failure in QList<T>::operator[]: "index out of range", file /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qlist.h, line 575
12:23:02: /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/mdi/mdi crashed.


Array;


C++
const QStringList list_array[10]
   {
       { "SubWindow terminal     (QMdiArea )",
           "SubWindow hcitool      (QMdiArea )",
           "SubWindow bluetoothctl (QMdiArea )",
           "SubWindow system       (QMdiArea )" },

       { "SubsubWindow bluetoothctl help        (QMdiArea )",
           "SubsubWindow bluetoothctl list  (QMdiArea )",
           "SubsubWindow bluetoothctl devices (QMdiArea )",
           "SubsubWindow bluetoothctl show  (QMdiArea )" },

       { "SubsubWindow hcitool        (QMdiArea )",
           "SubsubWindow hcitool   dev  (QMdiArea )",
           "SubsubWindow hcitool   scan (QMdiArea )",
           "SubsubWindow hcitool   inq  (QMdiArea )"}
   };





Code:


C++
for (index_array = 0; index_array <  list_array[index_array].size(); ++index_array  )
 {
     text = " index array ";
     text += QString::number(index_array);
     text += "Array size ";
     text += QString::number(list_array[index_array].size() );
     qDebug() << text;

 for (index_main = 0; index_main < list_array[index_array][index_main].size(); ++index_main)
 {
     text = " main menus  ";
     text += QString::number(index_main);
     text += " ";
     text += list_array[index_array][index_main];
     text += "main menu size ";
     text += QString::number(list_array[index_array][index_main].size());
     qDebug() << text;
 }
 }


modified 15-Jan-24 18:16pm.

AnswerRe: Loop thru two dimensional array Pin
jeron115-Jan-24 9:31
jeron115-Jan-24 9:31 
GeneralRe: Loop thru two dimensional array Pin
Salvatore Terress15-Jan-24 9:50
Salvatore Terress15-Jan-24 9:50 
AnswerRe: Loop thru two dimensional array Pin
k505415-Jan-24 10:45
mvek505415-Jan-24 10:45 
GeneralRe: Loop thru two dimensional array Pin
Salvatore Terress15-Jan-24 12:28
Salvatore Terress15-Jan-24 12:28 
AnswerSOLVED Re: Loop thru two dimensional array - edited Pin
Salvatore Terress15-Jan-24 12:49
Salvatore Terress15-Jan-24 12:49 
QuestionRe: SOLVED Re: Loop thru two dimensional array - edited Pin
jeron116-Jan-24 6:39
jeron116-Jan-24 6:39 
AnswerRe: SOLVED Re: Loop thru two dimensional array - edited Pin
Salvatore Terress16-Jan-24 7:20
Salvatore Terress16-Jan-24 7:20 
QuestionAdding "checkable " in Qt QMenu / QAction using C++ partially fails Pin
Salvatore Terress13-Jan-24 16:29
Salvatore Terress13-Jan-24 16:29 
AnswerRe: Adding "checkable " in Qt QMenu / QAction using C++ partially fails Pin
Richard MacCutchan13-Jan-24 21:09
mveRichard MacCutchan13-Jan-24 21:09 
AnswerRe: Adding "checkable " in Qt QMenu / QAction using C++ partially fails Pin
Dave Kreskowiak14-Jan-24 6:06
mveDave Kreskowiak14-Jan-24 6:06 
AnswerRe: Adding "checkable " in Qt QMenu / QAction using C++ partially fails Pin
jschell15-Jan-24 4:00
jschell15-Jan-24 4:00 
GeneralRe: Adding "checkable " in Qt QMenu / QAction using C++ partially fails Pin
Salvatore Terress15-Jan-24 7:06
Salvatore Terress15-Jan-24 7:06 
Questionmemory allocation failure Pin
mike741111-Jan-24 1:28
mike741111-Jan-24 1:28 
AnswerRe: memory allocation failure Pin
Mircea Neacsu11-Jan-24 1:37
Mircea Neacsu11-Jan-24 1:37 
GeneralRe: memory allocation failure Pin
mike741111-Jan-24 3:28
mike741111-Jan-24 3:28 
GeneralRe: memory allocation failure Pin
Richard MacCutchan11-Jan-24 3:35
mveRichard MacCutchan11-Jan-24 3:35 
GeneralRe: memory allocation failure Pin
Mircea Neacsu11-Jan-24 3:40
Mircea Neacsu11-Jan-24 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.