Okay so I am trying to pass a char pointer to another function. I can do this with an array of a char but cannot do with a char pointer. Problem is I don\'t know the size of
If you change the value of the pointer in a function, it will remain changed only in that one function call. Don't mess your head with pointers and try:
void func(int i){
i=5;
}
int main(){
int i=0;
func(i);
printf("%d\n",i);
return 0;
}
The same with your pointer. You do not change the address it points to.
If you assign to a variable passed by value, the variable outside the function will remain unchanged. You could pass it by a pointer (to pointer) and change it by dereferrencing it and it's the same with an int - in this case, it doesn't matter if the type is int or char * .