31.07.2014, 09:14
For example.. its like..
it had errros same as yours... change it to..
For array assignment, the arrays on the left and the right side of the assignment operator must have the same number of dimensions. In addition:
for multi-dimensional arrays, both arrays must have the same size;
for single arrays with a single dimension, the array on the left side of the assignment operator must have a size that is equal or bigger than the one on the right side.
In the above code, we try to fit 12 characters in an array that can only support 8. By increasing the array size of the destination, we can solve this. Note that a string also requires a null terminator so the total length of "Hello World!" plus the null terminator is, in fact, 13...
Quote:
new destination[8]; new msg[] = "Hello World!"; destination = msg; |
Quote:
new destination[13]; new msg[] = "Hello World!"; destination = msg; |
for multi-dimensional arrays, both arrays must have the same size;
for single arrays with a single dimension, the array on the left side of the assignment operator must have a size that is equal or bigger than the one on the right side.
In the above code, we try to fit 12 characters in an array that can only support 8. By increasing the array size of the destination, we can solve this. Note that a string also requires a null terminator so the total length of "Hello World!" plus the null terminator is, in fact, 13...