|
-
Feb 23rd, 2002, 09:27 PM
#1
Thread Starter
Stuck in the 80s
Two Questions With String
I'm using string.h and have two questions:
1) What would be the easies way to make an array of strings? Something like:
Code:
string mystring[] = "dude","what's","up"
Instead of declaring each of them one by one.
2) I've seen alot of examples of a Trim() function using a char array, but I haven't seen any for string. Does anybody have an example?
Thanks
-
Feb 24th, 2002, 04:14 AM
#2
transcendental analytic
Trim would look like this:
int first=s.find_first_not_of(32)
return s.substr(s,first,s.find_last_not_of(32)-first);
an array of strings
string x[10];
or a vector:
vector<string> x;
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2002, 08:14 AM
#3
Thread Starter
Stuck in the 80s
Thanks. I'll give it a try when I get home from work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|