Hallo,
I've got a weird issue here and I hope some one can help me finding the cause.
I have a function where I declared an array of strings (string_list). I pass the array to a function that does modifactions to the array. Whenn I address the string array index by index all values are stored properly. When I loop through the array incrementing the index automatically only the last index value will be stored in ALL positions.
Why is that? Or what am I doing wrong?
//this is the passing a string array to another function int calling_function { char *string_list[MAX_PATHNAME_LEN]; //< store strings in here function_called( string_list ); // passing a pointer to a string array return 0; } // this is the function receiving a reference to a string array to store data int function_called( char* output_list[] ) {
int i = 0; // counter variable /*This works and the right values are stored in output_list*/ output_list[0] = "02"; output_list[1] = "12"; output_list[2] = "22"; output_list[3] = "32"; output_list[4] = "42"; output_list[5] = "52"; output_list[6] = "622"; output_list[7] = "72"; /*this does not work and will store '31' in all places of the array*/ while( i < 32 ) { Fmt( sample, "%s<%d", i ); // increment value output_list[ i ] = sample; // store value in index i = i ++; // increment counter } }
Thanks!