jeudi 23 juin 2016
Create array structure using a for loop
I'm not exactly sure what to name this question, but I am working on a gui in Visual Studio 2015, using MFC c++.
I have a structure that looks like this
static dataCollect::StatSrcListL_t s_struct9[] =
{
// Name Addr Type Mask Stride User
{ "Rx PMA Reset Done", statsRW::statMode9egrDeltDat, dataCollect::Irg, statMode9egrDelt_rxPmaRstDoneMask, 0x000 },
{ "Rx Reset Done", statsRW::statMode9egrDeltDat, dataCollect::Irg, statMode9egrDelt_rxResetDoneMask, 0x0000 },
{ "Rx Buffer Underflow", statsRW::statMode9egrDeltDat, dataCollect::IrgErr, statMode9egrDelt_rxBufUflwMask, 0x0000 },
{ "Rx Buffer AE", statsRW::statMode9egrDeltDat, dataCollect::IrgErr, statMode9egrDelt_rxBufAeMask, 0x0000 },
{ "Rx Buffer AF", statsRW::statMode9egrDeltDat, dataCollect::IrgErr, statMode9egrDelt_rxBufAfMask, 0x0000 },
{ "Rx Buffer Overflow", statsRW::statMode9egrDeltDat, dataCollect::IrgErr, statMode9egrDelt_rxBufOflwMask, 0x0000 },
{ "PRBS Err Det", statsRW::statMode9egrDeltDat, dataCollect::IrgErr, statMode9egrDelt_prbsErrMask, 0x0000 },
{ "PRBS Lck Det", statsRW::statMode9egrDeltDat, dataCollect::Irg, statMode9egrDelt_prbsLckMask, 0x0000 },
{ "Tx Reset Done", statsRW::statMode9ingDeltDat, dataCollect::Irg, statMode9ingDelt_txRstDoneMask, 0x000 },
{ "Tx PMA Reset Done", statsRW::statMode9ingDeltDat, dataCollect::Irg, statMode9ingDelt_txPmaRstDoneMask, 0x000 },
{ "Tx Buf OFlow/Uflow", statsRW::statMode9ingDeltDat, dataCollect::IrgErr, statMode9ingDelt_txBufOfUfMask, 0x0000 },
{ "Pwr Good", statsRW::statMode9ingDeltDat, dataCollect::Irg, statMode9ingDelt_pwrGoodMask, 0x000 },
{ "QPLL Lock Status", statsRW::statMode9ingDeltDat, dataCollect::Irg, 1 << statMode9ingDelt_qpllLock, 0x000 }
};
I have been trying to play around with different ways of making statMode9egrDeltDat have the number assigned dynamically. Depending on the project being used with it could range from about 10 to 50 of these being made and writing that individually 50 times in the code seems like a bit of a waste of time and space. Everything is the same except the number 9 (in this example) would start at 0, 1, 2, 3 so on and so on.
So my question is, how would I be able to put the above code into a loop to increment the number to a specified number.
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire