I have a class in which a declare a series of arrays of chars and I am getting a real stinker problem. for example I declare the arrays like this
char Temp1[5];
char Temp2[5];
char Temp3[5];
Or
char Temp1[5], Temp2[5], Temp3[5];
Anyway the program is taking the first array as a array of 15 elements, the second as a array or 10 and the third as a array of 5, so I can write to Temp3[0] by doing either:
Temp3[0] = 'x';
or
Temp1[10] = 'x';
This is doing my head in big time as if I so a strcpy(Temp3, Temp1) I get a access overun, as it is trying to put 15 chars into a 5 char array!!!!... If I declare the arrays locally it doesnt occur just if I declare them in the class declaration.
Im stumped and half about to smash up my monitor as I can find no logical explanation for this.
Even before I put anything in the arrays, just declare them, If I step through to the first line of code and put watched on the arrays, it shows the last with 5 random elements the second with 10 (the last five being from the the last array) and the first with 15(the last 10 being form the second and last). Its as if it isnt putting in the end of string marker or somthing. I have even declared a single array at the end, of 10 elements and it gives me a array of 12 elements...... Please help.....please please, I told my bos it would only take me half a day to write this small program and now Im stuck on what should be beginers stuff :-S
thanks in advance
char Temp1[5];
char Temp2[5];
char Temp3[5];
Or
char Temp1[5], Temp2[5], Temp3[5];
Anyway the program is taking the first array as a array of 15 elements, the second as a array or 10 and the third as a array of 5, so I can write to Temp3[0] by doing either:
Temp3[0] = 'x';
or
Temp1[10] = 'x';
This is doing my head in big time as if I so a strcpy(Temp3, Temp1) I get a access overun, as it is trying to put 15 chars into a 5 char array!!!!... If I declare the arrays locally it doesnt occur just if I declare them in the class declaration.
Im stumped and half about to smash up my monitor as I can find no logical explanation for this.
Even before I put anything in the arrays, just declare them, If I step through to the first line of code and put watched on the arrays, it shows the last with 5 random elements the second with 10 (the last five being from the the last array) and the first with 15(the last 10 being form the second and last). Its as if it isnt putting in the end of string marker or somthing. I have even declared a single array at the end, of 10 elements and it gives me a array of 12 elements...... Please help.....please please, I told my bos it would only take me half a day to write this small program and now Im stuck on what should be beginers stuff :-S
thanks in advance