Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int max(int a, int b)
- {
- static int flag{};
- return a > b ? a : b;
- }
- int main()
- {
- int numI{ 42 };
- float numF{ 42.0 };
- for (int i{ 0 }; i < 4; ++i)
- {
- std::cout << "numI[" << i << "]" << (int)((uint8_t*)&numI)[i] << "\n";
- }
- for (int i{ 0 }; i < 4; ++i)
- {
- std::cout << "numF[" << i << "]" << (int)((uint8_t*)&numF)[i] << "\n";
- }
- //int num{ 42 };
- //int otherNum{ 32 };
- //float temp{ 42.0 };
- //int* ptr{ &num };
- //float* ptrFl{ &temp };
- //char symb{ 'A' };
- //char* ptrCh{ &symb };
- //std::cout << "Value of *ptr = " << *ptr << '\n'; //42
- //ptr = (int*)&symb;
- //std::cout << "Value of ptr = " << ptr << '\n'; //XX the same!!
- //std::cout << "Value of ptrCh = " << (int*)ptrCh << '\n';//XX the same!!
- //std::cout << "Value of *ptr = " << *ptr << '\n'; //42???
- //std::cout << "Value of *ptrCh = " << *ptrCh << '\n'; // 42
- //return 0;
- /*std::cout << "Enter some number";
- std::cin >> *ptr;
- std::cout << "Value of num = " << *ptr << '\n';
- std::cout << "Value of num = " << num << '\n';
- *ptr += 10;
- std::cout << "Value of num = " << *ptr << '\n';
- std::cout << "Value of num = " << num << '\n';
- ptr = &otherNum;
- std::cout << "Enter some number";
- std::cin >> *ptr;
- std::cout << "Value of num = " << *ptr << '\n';
- std::cout << "Value of num = " << num << '\n';
- *ptr += 10;
- std::cout << "Value of num = " << *ptr << '\n';
- std::cout << "Value of num = " << num << '\n';*/
- //int x{ 42 };
- //int y{ 65 };
- //bool flag{ true };
- //const int arrSize{ 5 };
- //char arr[arrSize];
- //double number{ 333.33 };
- //int* ptrI{&x};
- //std::cout << "Addr of x is " << &x << " ptrI = " << ptrI << " *ptrI = " << *ptrI << '\n';
- //ptrI = &y;
- //*ptrI = 456;
- //std::cout << *ptrI << '\n';
- //std::cout << "Addr of x is " << &x << " ptrI = " << ptrI << " *ptrI = " << *ptrI << '\n';
- //std::cout << "Addr of y is " << &y << " ptrI = " << ptrI << " *ptrI = " << *ptrI << '\n';
- //return 0;
- //bool* ptrB{ &flag };
- //const int* ptrCI{ &arrSize };
- //double* ptrD{ &number };
- //*ptrI = 333;
- //
- //std::cout << " x = " << x << '\n';
- //std::cout <<"Addr of x is " << &x << " ptrI = " << ptrI << " *ptrI = " << *ptrI << '\n';
- ////std::cout << "Addr of flag is " << &flag << " ptrB = " << ptrB << " *ptrB = " << *ptrB << '\n';
- /////std::cout << "Addr of arrSize is " << &arrSize << " ptrCI = " << ptrCI << " *ptrCI = " << *ptrCI << '\n';
- ////std::cout << "Addr of number is " << &number << " ptrB = " << ptrB << " *ptrB = " << *ptrB << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment