Original Post
im creating a function which gets passed a pointer to a pointer, and i want the function to change what the pointer in the calling function points to.
ex:
main source file
myHeader.h
this doesnt compile, im getting a "assignment discards qualifiers from pointer target type" error.
so how would i go about doing this? having the called function change what a passed pointer points to so that when the function returns, the pointer in the calling function will point to something different?
thanx,
- jeremiah
inlovewithGod.com
// MAIN
#include "myHeader.h"
void main()
{
Uint8 *errmsg;
if ( some_func(&errmsg) == -1 )
{
// function failed, print out its error message
printf("error: %s\n", errmsg);
}
else
{
// function was successful, do whatever
}
}
const Uint8 myReturnErr[] = "couldnt do something (whatever).";
Uint32 some_func(Uint8 **err)
{
// do whatever
// if fail, make pointer point to ''myReturnErr''.
*err = myReturnErr[0];
return -1;
// if successful, just return 0 (success)
return 0;
}