C / C++ Error: Pointer Variable Undefined Inside Function
From My Java Experience It Was Not Hard to Get a Grip. a Pretty Simple Function: Void Update(Float * P, Float Value) { *P = Value; } the Compiler Is...
From my Java experience it was not hard to get a grip.
A pretty simple function:
void update(float * p,float value)
{
*p = value;
}
The compiler is complaining that identifier p is undefined.
I thought *p would dereference the pointer and store value in it.
1 Answer
OK, so your code looks right, I have to assume the error message is coming from somewhere else. You can try out this "full" version of your program:
#include <stdio.h>
void update(float *p, float value){
*p = value;
}
int main(int argc, char *argv[]){
float p = 3.0;
update(&p, 5.0);
printf("%f\n", p);
}
Just copy and paste that and respond with any error/warnings you get. If it works fine, then you've miss typed something in your code, if it still gives you issues there's something up with your environment and we'll need more details.