Can I use if (pointer) instead of if (pointer != NULL)?
Is it safe to check a pointer to not being NULL by writing simply if(pointer) or do I have to use if(pointer != NULL)? 14 Answers 14
Is it safe to check a pointer to not being NULL by writing simply if(pointer) or do I have to use if(pointer != NULL)? 14 Answers 14
How do pointers-to-pointers work in C? When might you use them? 14 Answers 14
I am relatively new to C and I need some help with methods dealing with arrays. Coming from Java programming, I am used to being able to say int [] method()in order to return an array. However, I have found out that with C you have to use pointers for arrays when you return them. … Read more
I just saw a picture today and think I’d appreciate explanations. So here is the picture: I found this confusing and wondered if such codes are ever practical. I googled the picture and found another picture in this reddit entry, and here is that picture: So this “reading spirally” is something valid? Is this how … Read more
I was reading the answers to this question C++ pros and cons and got this doubt while reading the comments. programmers frequently find it confusing that “this” is a pointer but not a reference. another confusion is why “hello” is not of type std::string but evaluates to a char const* (pointer) (after array to pointer … Read more
In a reputable source about C, the following information is given after discussing the & operator: … It’s a bit unfortunate that the terminology [address of] remains, because it confuses those who don’t know what addresses are about, and misleads those who do: thinking about pointers as if they were addresses usually leads to grief… … Read more
In the following bit of code, pointer values and pointer addresses differ as expected. But array values and addresses don’t! How can this be? Output my_array = 0022FF00 &my_array = 0022FF00 pointer_to_array = 0022FF00 &pointer_to_array = 0022FEFC #include <stdio.h> int main() { char my_array[100] = “some cool string”; printf(“my_array = %p\n”, my_array); printf(“&my_array = %p\n”, … Read more
This question already has answers here: What is the difference between const int*, const int * const, and int const *? (22 answers) What is the difference between char * const and const char *? (19 answers) Closed 8 years ago. I want to know the difference between const int* ptr; and int * const … Read more
What’s the difference between char* name which points to a constant string literal, and const char* name 9 Answers 9
Why do most C programmers name variables like this: int *myVariable; rather than like this: int* myVariable; Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic? 12 Answers 12