Answer the question
In order to leave comments, you need to log in
How to compare pointers?
There is a code
I need to compare the pointers num and endptr, namely to get something like this
num + strlen(num) == *endptr
But when I try to get the value of the pointer as a number, the program crashes. And it works weird.
In the code, I assign the value of the endptr pointer to the variable k. And then I output this value. And it works.
However, if I try to compare the value of k, seemingly independent, with some other number (this if), then the program crashes.
I do not understand why.
How do I end up comparing pointers?
Answer the question
In order to leave comments, you need to log in
It was necessary to bring the problematic code directly in the question
. The problem is naturally here:
char ** endptr;
long a = strtol(num, endptr, 10);
char * endptr;
long a = strtol(num, &endptr, 10);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question