typedef struct (?)
-
Hello, I have a function that returns several strings. This function is run over and over again many times. I would like to store all the returned strings in an array. I'm assuming that I have to use a struct. But, how do I get the values inside by index after its created. In VB (yea, i know.) :) It would be something like this: Private Type StrData String1 as string String2 as String End Type Then to access the array it would be something like this: rtn = StrData.String1(0) So, how do I convert this to C++ and MFC? Thanks! Frank :)
-
Hello, I have a function that returns several strings. This function is run over and over again many times. I would like to store all the returned strings in an array. I'm assuming that I have to use a struct. But, how do I get the values inside by index after its created. In VB (yea, i know.) :) It would be something like this: Private Type StrData String1 as string String2 as String End Type Then to access the array it would be something like this: rtn = StrData.String1(0) So, how do I convert this to C++ and MFC? Thanks! Frank :)
I don't understand what rtn = StrData.String1(0) means exactly. What is the (0) there for? "String1" isn't an array. Anyway, to make a typedef'd struct:
typedef struct
{
CString String1, String2;
} StrData;To make an array of those, you can use a linked list (since it sounds like you don't know exactly how many structs you'll have). Use
std::list<StrData>
in STL, orCList<StrData, StrData&>
in MFC. -
I don't understand what rtn = StrData.String1(0) means exactly. What is the (0) there for? "String1" isn't an array. Anyway, to make a typedef'd struct:
typedef struct
{
CString String1, String2;
} StrData;To make an array of those, you can use a linked list (since it sounds like you don't know exactly how many structs you'll have). Use
std::list<StrData>
in STL, orCList<StrData, StrData&>
in MFC.Thanks Mike. In VB, rtn = StrData.String1(0) the (0) is the index of the n'th (where n is just a number) String1 object contained in the data type StrData. (I think) :) I'm afraid I'm new to using "Linked Lists". Could you expand a bit on the usage in MFC? What do I do with the code CList. Thanks again, Frank
-
Hello, I have a function that returns several strings. This function is run over and over again many times. I would like to store all the returned strings in an array. I'm assuming that I have to use a struct. But, how do I get the values inside by index after its created. In VB (yea, i know.) :) It would be something like this: Private Type StrData String1 as string String2 as String End Type Then to access the array it would be something like this: rtn = StrData.String1(0) So, how do I convert this to C++ and MFC? Thanks! Frank :)
See: http://home.socal.rr.com/samhobbs/VC/Collections.html CStringList is really easy to use but the MFC documentation is not. I hope the example in the above page is easy though.