Literally i can use
a[i]
orp1[i]
?
Yes, dereferencing works the same way for a raw array symbol or a pointer.
The a
symbol in your example will decay to a int*
pointer whenever used as such (p1=a;
).
Using code like p1[i]
is just syntactic sugar for *(p1 +i)
.
More Related Contents:
- what is the different between 'new()' int and 'int *p' [closed]
- How to optimize traversing a range of numbers?
- Can I call a constructor from another constructor (do constructor chaining) in C++?
- Why aren’t my include guards preventing recursive inclusion and multiple symbol definitions?
- Reading a password from std::cin
- Initialization Order of Class Data Members
- Global memory management in C++ in stack or heap?
- Unresolved external symbol in object files
- Finding all the subsets of a set
- Creating an input stream from constant memory
- Sleep function in C++
- How to create NVIDIA OpenCL project
- C++ Winsock P2P
- Why don’t the C or C++ standards explicitly define char as signed or unsigned?
- What do each memory_order mean?
- Create new C++ object at specific memory address?
- How to read a growing text file in C++?
- 5 years later, is there something better than the “Fastest Possible C++ Delegates”?
- When should you use the “this” keyword in C++? [duplicate]
- how to test a string for letters only
- Error with address of parenthesized member function
- Using bts assembly instruction with gcc compiler
- Why sizeof int is wrong, while sizeof(int) is right?
- Does C have One Definition Rule like C++?
- Why does pointer to int convert to void* but pointer to function convert to bool?
- How to enable /std:c++17 in VS2017 with CMake
- Simple for() loop benchmark takes the same time with any loop bound
- How to differentiate (when overloading) between prefix and postfix forms of operator++? (C++)
- Concatenate compile-time strings in a template at compile time?
- How to force GCC to assume that a floating-point expression is non-negative?