Array of CString 
Author Message
 Array of CString

Hello friends i am trying to decalre an array of CString type by
writing the following syntax

 CString anArray[10];
 anArray[0]="HI";

But this syntax is not working my main aim is to store strings in an
array, the strings are like "ButtonPress()". i want to store a number
of strings of this type in an array but CString is not allowing me
that Kindly refer me some thing else
regards
Basim



Tue, 01 Nov 2005 18:41:56 GMT  
 Array of CString


Quote:
> Hello friends i am trying to decalre an array of CString type by
> writing the following syntax

>  CString anArray[10];
>  anArray[0]="HI";

anArray[0].Append("HI");
should work nicely

Check the methods available for CString.
HTH,
--
Alan Walkington
Technical Staff
United Defense, San Jose



Wed, 02 Nov 2005 02:31:14 GMT  
 Array of CString
How about using CStringArray:

     CStringArray strArray;
     CString str(_T("Hello World"));

     strArray.Add(str);

--
Ajay Kalra [MVP - VC++]


Quote:
> Hello friends i am trying to decalre an array of CString type by
> writing the following syntax

>  CString anArray[10];
>  anArray[0]="HI";

> But this syntax is not working my main aim is to store strings in an
> array, the strings are like "ButtonPress()". i want to store a number
> of strings of this type in an array but CString is not allowing me
> that Kindly refer me some thing else
> regards
> Basim



Wed, 02 Nov 2005 07:32:12 GMT  
 Array of CString
That should work OK.  I entered the following:

CString myStrings[10];

myStrings[0]="Line 1";
myStrings[1]="Line 2";

AfxMessageBox(myStrings[0]);
AfxMessageBox(myStrings[1]);

and it worked just fine (did what I expected).

CStringList or CStringArray work nicely for this sort of thing, but I much
prefer CStringArray.  The nice thing about using the collection class is
that it will grow dynamically as you need to add more elements.

Tom


Quote:
> Hello friends i am trying to decalre an array of CString type by
> writing the following syntax

>  CString anArray[10];
>  anArray[0]="HI";

> But this syntax is not working my main aim is to store strings in an
> array, the strings are like "ButtonPress()". i want to store a number
> of strings of this type in an array but CString is not allowing me
> that Kindly refer me some thing else
> regards
> Basim



Sat, 05 Nov 2005 08:05:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dynamic of array of CString

2. Store array of CString in CList?

3. TCHAR Array to CString

4. Array of CString references

5. Array of CString's?

6. How do I convert array of VARIANT to array of CString?

7. How do I convert a VARIANT array to a CString array

8. BSTR* array -> CString conversion problem

9. Accessing and CString array declaration problem

10. cstring vs. tchar/char array

11. Array of structures having CString objects

12. Cstring -> array

 

 
Powered by phpBB® Forum Software