hau can i declare a string variiable?
i forgot it....
and is this legal?
string arr[1]={"xxxx","ddddddd"};
Printable View
hau can i declare a string variiable?
i forgot it....
and is this legal?
string arr[1]={"xxxx","ddddddd"};
Moved from the CodeBank.
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";
It works, yes. It's just rarely done.
tnx a lot guys but it doesnt work...............
but nvm i solved it :D
it just need multiple arrays...
coz every element in the array can store 1 char only so i need to set first the size of every array by creating multiple arrays :D
arr[1][2]={"hi","xx"} <<<=========== now this code is valid :D
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.