Created
August 2, 2017 14:51
-
-
Save odeblic/2f253dc50d3abeb336a4f33a4eb53761 to your computer and use it in GitHub Desktop.
Representations of bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstddef> | |
void action(char arg) | |
{ | |
std::cout << "char arg -> " << (int)arg << "\n"; | |
} | |
void action(signed char arg) | |
{ | |
std::cout << "signed char arg -> " << (int)arg << "\n"; | |
} | |
void action(unsigned char arg) | |
{ | |
std::cout << "unsigned char arg -> " << (int)arg << "\n"; | |
} | |
void action(std::byte arg) | |
{ | |
std::cout << "byte arg -> " << (int)arg << "\n"; | |
} | |
int main() | |
{ | |
char c{}; | |
signed char sc{}; | |
unsigned char uc{}; | |
std::byte b{}; | |
action(c); | |
action(uc); | |
action(sc); | |
action(b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment