fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. #include <ctime>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <cmath>
  9.  
  10. using namespace std;
  11. //int to hex
  12. string itoh(unsigned int x, int size);
  13. //int to bin
  14. string itob(unsigned int x, int size);
  15. //bin to int
  16. unsigned int btoi(string bin);
  17. //hex to int
  18. unsigned int htoi(string hex);
  19. //char(0x**) to hex
  20. string ctoh(unsigned char c);
  21. //hex to bin
  22. string htob(string hex);
  23. //bin to hex
  24. string btoh(string bin);
  25. //float to hex
  26. string ftoh(float f);
  27. //hex to float
  28.  
  29. int main() {
  30. // your code goes here
  31. cout << itoh(10,10);
  32. return 0;
  33. }
  34.  
  35. //int hex bin 型の変換
  36. string itoh(int x, int size){
  37. char hexbuf[16];
  38. string hexstr;
  39.  
  40. sprintf( hexbuf, "%X", x);
  41. hexstr = hexbuf;
  42. while(hexstr.length() < size){
  43. if(x >= 0) hexstr = "0" + hexstr;
  44. if(x < 0) hexstr = "F" + hexstr;
  45. }
  46. while(hexstr.length() > size){
  47. hexstr.erase(hexstr.begin());
  48. }
  49. return hexstr;
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/ZZqyOL/cci8TMyr.o: In function `main':
prog.cpp:(.text.startup+0x17): undefined reference to `itoh[abi:cxx11](unsigned int, int)'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty