diff --git a/02_MENT/a.out b/02_MENT/a.out new file mode 100755 index 0000000..aacdc59 Binary files /dev/null and b/02_MENT/a.out differ diff --git a/02_MENT/build.sh b/02_MENT/build.sh old mode 100644 new mode 100755 index 04a14d3..7efe4e7 --- a/02_MENT/build.sh +++ b/02_MENT/build.sh @@ -1,3 +1,10 @@ #!/bin/bash -clang++ -std=c++14 -I../helpers/ -o limits.out limits_println.cpp -clang++ -std=c++14 -I../helpers/ -o println.out printlnDemo.cpp + +rm *.out + +clang++-6.0 -std=c++14 -I../helpers/ -o limits.out limits_println.cpp +clang++-6.0 -std=c++14 -I../helpers/ -o println.out printlnDemo.cpp + +clang++-6.0 -std=c++14 main_02_MENT.cpp + +./a.out diff --git a/02_MENT/limits.out b/02_MENT/limits.out new file mode 100755 index 0000000..e3a35a4 Binary files /dev/null and b/02_MENT/limits.out differ diff --git a/02_MENT/main_02_MENT.cpp b/02_MENT/main_02_MENT.cpp index caa166f..faf6262 100644 --- a/02_MENT/main_02_MENT.cpp +++ b/02_MENT/main_02_MENT.cpp @@ -1,31 +1,43 @@ // file: main_02_MENT.cpp // THIS IS C++, use clang++ -#include "../helpers/println.hpp" #include +#include "../helpers/println.hpp" + struct PascalString{ int length; // number of chars used char characters[256]; // chars of some character string }; -int hexDigitToInt(char hexDigit){ -int value = -1; -// TBD +int hexDigitToInt(char hexDigit) { +int value = 0; + +if(hexDigit > 47 && hexDigit < 58) + value = hexDigit - 48; + +if(hexDigit > 96 && hexDigit < 103) + value = hexDigit - 97 + 10; + return value; } -int hexStringToInt(PascalString binaryDigits){ +int hexStringToInt(PascalString binaryDigits) { int returnValue = -1; return returnValue; } -int main(int argc, char** argv, char** envp){ +int main(int argc, char** argv, char** envp) { PascalString s = {3, '1', '0', '0'}; PascalString s2 = {4, 'f', 'f', 'f', 'f'}; println(hexStringToInt(s)); println(hexStringToInt(s2)); + + + println(hexDigitToInt('D')); + println(hexDigitToInt('9')); + println(hexDigitToInt('2')); return 0; } diff --git a/02_MENT/println.out b/02_MENT/println.out new file mode 100755 index 0000000..82e5fb3 Binary files /dev/null and b/02_MENT/println.out differ