Teen Programmers Unite  
 

 

Return to forum top

C++ string array (collection?)

Posted by sinple [send private reply] at January 01, 2003, 11:31:42 PM

hello
i need a way in C++ to store strings (set at runtime) in an array referenced by an index, essentially a c++ collection out of vb.
If any one knows how to do this please give me an example of what you mean. thankyou!

also if this an ok FileExist function? i mite have made sum mistakes :)

ifstream blah("sexual.m3n");
if !blah
{
//file don't exist
return;
}

Posted by CViper [send private reply] at January 02, 2003, 05:57:47 AM

there are many ways to do the first; one way would be with an std::string and an std::vector<string>. Check the STL docs ( http://www.sgi.com/tech/stl/ ) for more info on those.
An other approach would be with alot of pointers etc (psion would probably kill me if I tell you more about this, as it's not very OO :D)

The second part is ok, provided you put some parantheses around !blah, eg

...
if( !blah )
...
Posted by sinple [send private reply] at January 05, 2003, 06:48:52 AM

excellent.
thanks alot CViper!

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.