Skip to content

Instantly share code, notes, and snippets.

@jitpaul
Created April 26, 2018 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpaul/4035ead7e011729de50cf29603a0806c to your computer and use it in GitHub Desktop.
Save jitpaul/4035ead7e011729de50cf29603a0806c to your computer and use it in GitHub Desktop.
TypeCasting
#include <iostream>
using namespace std;
int main(){
char a = 'c';
int *b = (int*)&a;
cout<<*b; //Undefined behavior because integer pointer tries to access 4 bytes of memory although only 1 byte belongs to it.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment