Which command is more efficient?
*(ptr+1) or ptr[1]
Answers were Sorted based on User's Feedback
Answer / purna
*(ptr+1);
Internally the same operation is performed with the next
one also.
it takes less time.
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / poornima
If ptr is declared as a pointer like int *ptr; *(ptr+1) is
more efficient.
If ptr is declared as an array like int ptr[20]; ptr[1] is
more efficient.
So, it depends upon how we r declaring ptr as a pointer or
as an array.
| Is This Answer Correct ? | 1 Yes | 3 No |
How do I get a null pointer in my programs?
What is the scope of an external variable in c?
What is volatile variable in c with example?
Which one would you prefer - a macro or a function?
Where are c variables stored in memory?
What is the difference between ‘g’ and “g” in C?
What is meant by global static? why we have to use static variable instead of Global variable
What does & mean in scanf?
What is key word in c language?
What is the return type of sizeof?
Explain heap and queue.
Explain the difference between #include "..." And #include <...> In c?