Skip to content

Instantly share code, notes, and snippets.

@zloyrusskiy
Created April 3, 2015 18:51
Show Gist options
  • Save zloyrusskiy/c9cb374460a86e515d12 to your computer and use it in GitHub Desktop.
Save zloyrusskiy/c9cb374460a86e515d12 to your computer and use it in GitHub Desktop.
Valerke example
#include <iostream>
using namespace std;
int main() {
char * str { "Hello" };
int * int_hz = (int *) str;
cout << str << endl;
cout << (void *)str << endl;
cout << int_hz << endl;
cout << hex << *int_hz << endl;
return 0;
}
### result
g++ main.cpp -std=c++11 -o main && ./main
main.cpp: In function ‘int main()’:
main.cpp:6:24: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
char * str { "Hello" };
^
Hello
0x400be5
0x400be5
6c6c6548
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment