Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array of objects

Status
Not open for further replies.

shilpashetty27

Technical User
Apr 12, 2007
32
CA
Hi all,


I’m trying to create an array of a string object whose contents I need to access later. To be more specific:


string data[] = {“10”,”11”, “12”};

Using a for loop I want to access the first, second and third element of the array above.

As I understand it, the above declaration is incorrect. Any ideas on how I can go about doing this are appreciated.

Thanks in advance!
Shilpa



 
I use to declare them as:
char * Data[] = {"String1", "String2", "String3"};

That way Data[0] points on the first strings first character, to access the individual characters use *(Data[0] + Index) where 'Index' is the characternumber to pick.

Totte
Keep making it perfect and it will end up broken.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top