OK, I know I'm probably going mad BUT this project is driving me mad now, so...
- to return a string from a function you need to use a pointer?
- this code (as an example) should work...?
void change_it(char *my_string) {
*my_string = "hello\0";
return;
}
void main (void) {
char sMyString[10] = "test\0";
char *pMyString = &sMyString;
change_it(pMyString);
}
Am I right in thinking that this would change the value of sMyString to 'hello' in the main routine, via the pointer pMyString?
If not, could anyone please provide an example? Thanks and sorry for asking but I'm trying to write code for devices which have v. small stacks (<16K) and I'm not sure if it's my code that's wrong or just the fact that the pointers aren't working because of the size / style of the stack.
Thanks!
PetitPal.
- to return a string from a function you need to use a pointer?
- this code (as an example) should work...?
void change_it(char *my_string) {
*my_string = "hello\0";
return;
}
void main (void) {
char sMyString[10] = "test\0";
char *pMyString = &sMyString;
change_it(pMyString);
}
Am I right in thinking that this would change the value of sMyString to 'hello' in the main routine, via the pointer pMyString?
If not, could anyone please provide an example? Thanks and sorry for asking but I'm trying to write code for devices which have v. small stacks (<16K) and I'm not sure if it's my code that's wrong or just the fact that the pointers aren't working because of the size / style of the stack.
Thanks!
PetitPal.