Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/09/01 09:16
Read: times


 
#13959 - RE: changing value using array of pointers
Mohit:
I think your program declares a vector of 4 pointers. It does not reserve memory for their contents, only for the pointers. Your code assigns constant strings following the declaration. I think that the compìler creates the strings to reside in code memory and initialize the pointers to the corresponding code memory address. In think this is the reason why you cannot change the chars in the strings.
If you can not declare a two-dimensional array, you must reserve a valid data memory space for your strings, and then initialize the 4 pointers to adrreses within that area.

For example:
unsigned char buffer[16];
unsigned char *p[4];
p[0]= buffer;
p[1]= buffer+4;
p[2]= buffer+8;
p[3]= buffer+12;
strcpy(p[0],"NIL");
// other initializations using constants
...
p[0][2]= '*';
// so you get "NI*".

I have reserved 4 chars for each string, because the final zero.

I think this will do.
Regards.

Alfredo

List of 5 messages in thread
TopicAuthorDate
changing value using array of pointers            01/01/70 00:00      
RE: changing value using array of pointers            01/01/70 00:00      
RE: changing value using array of pointers            01/01/70 00:00      
RE: changing value using array of pointers            01/01/70 00:00      
RE: changing value using array of pointers            01/01/70 00:00      

Back to Subject List