How would one go about putting the characters of a sting into the index of an array?
eg.
For i = 1 To 8
array(i) = "abcdefgh"
Next
I want array(1) to be a , array(2) to be b and so on.
Thanks
Printable View
How would one go about putting the characters of a sting into the index of an array?
eg.
For i = 1 To 8
array(i) = "abcdefgh"
Next
I want array(1) to be a , array(2) to be b and so on.
Thanks
The problem is: arrays start counting with zero, and zero is used by C to mark the end of a string so:Code:memset(arr,'\0',sizeof(arr)); // zero out the array
for (i=1;i<9;i++){
arr[i-1] = i;
}
will create an array with no length - like a null string in VB.Code:arr[0]=0;
So,
or something like that for the first elementCode:arr[0]=' ';
or this
my problem is I have no idea what you want.... :DCode:char c;
int i=0;
for (c='a';c<='h';c++){
arr[i++]=c;
}