What changes between these two ways?
int *ptr
and int* ptr
Both work the same way, but for my code or performance my program has difference?
#include <iostream>
using namespace std;
int main() {
int a(5);
int *ptr1 = &a;
int* ptr2 = &a;
cout << "a: (0x" << hex << uppercase << (uintptr_t)&a << ") = " << dec << a << endl;
cout << "ptr1: (0x" << hex << uppercase << (uintptr_t)ptr1 << ") = " << dec << *ptr1 << endl;
cout << "ptr2: (0x" << hex << uppercase << (uintptr_t)ptr2 << ") = " << dec << *ptr2 << endl;
return 0;
}
Output:
a: (0x61FE0C) = 5
ptr1: (0x61FE0C) = 5
ptr2: (0x61FE0C) = 5