change of values of the dynamic array,
August 8, 2009 at 9:56 PM
i used a dynamic array in my program, here's the fragment.
char *data_type, *identifier;
then after i allocated a memory for data_type and stored a value, and right after which i again allocated a memory for identifier, when i checked the value of data_type it actually changed....appending a garbage value at the last....
here's the algo:
-allocate memory for data_type -initialize data_type -store the string "void" to data_type (using puts(); i checked the value and it was exactly "void") -allocate memory for identifier (then i again checked the value for data_type and it was now "voidñ")
...i really had a hard time looking why the value of a dynamic array changed.....and i deduced that it changed due to another allocation of a dynamic array.....so why is that so? pls...anyone help....
View All Comments
| View Tutorial