Heres how you pass by reference:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LEN 50
void test(char **testptr)
{
strncpy(*testptr, "goodbye world", MAX_LEN);
}
int main()
{
char* testptr = (char*)malloc(MAX_LEN+1);
strncpy(testptr, "hello world", MAX_LEN);
printf("%s\n", testptr);
test(&testptr);
printf("%s\n", testptr);
free(testptr);
}
Theres some extra stuff in the code that you should get your head around if you want to work with strings in C. Basically allocating/freeing space and making sure you dont get buffer overflows.