|
-
May 17th, 2005, 09:07 PM
#1
Thread Starter
Junior Member
C/C++ string questions...
hau can i declare a string variiable?
i forgot it....
and is this legal?
string arr[1]={"xxxx","ddddddd"};
-
May 18th, 2005, 05:25 AM
#2
Re: C/C++ string questions...
-
May 18th, 2005, 07:04 AM
#3
Frenzied Member
Re: C/C++ string questions...
string s("hi"); string s= "hi";
This would be:
string arr[2]={"xxxx","ddddddd"};
But I don't know if that works or not. If not, you'll have to assign then separately: arr[0]="blah"; arr[1]= "blah2";
-
May 18th, 2005, 07:22 AM
#4
Re: C/C++ string questions...
It works, yes. It's just rarely done.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 26th, 2005, 01:43 AM
#5
Thread Starter
Junior Member
-
May 26th, 2005, 03:22 AM
#6
Re: C/C++ string questions...
No, it's not. You're initializing more strings than the array has space for, and longer ones at that (if you count the characters between quotes, you always need to add one).
The number between the brackets is the size of the array, not the highest accessible index, which is one less.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|