C_CPP/02_MENT/main_02_MENT.cpp

44 lines
839 B
C++
Raw Normal View History

2018-03-09 09:47:53 +01:00
// file: main_02_MENT.cpp
// THIS IS C++, use clang++
#include <iostream>
2018-03-16 18:03:32 +01:00
#include "../helpers/println.hpp"
2018-03-09 09:47:53 +01:00
struct PascalString{
int length; // number of chars used
char characters[256]; // chars of some character string
};
2018-03-16 18:03:32 +01:00
int hexDigitToInt(char hexDigit) {
int value = 0;
if(hexDigit > 47 && hexDigit < 58)
value = hexDigit - 48;
if(hexDigit > 96 && hexDigit < 103)
value = hexDigit - 97 + 10;
2018-03-09 09:47:53 +01:00
return value;
}
2018-03-16 18:03:32 +01:00
int hexStringToInt(PascalString binaryDigits) {
2018-03-09 09:47:53 +01:00
int returnValue = -1;
return returnValue;
}
2018-03-16 18:03:32 +01:00
int main(int argc, char** argv, char** envp) {
2018-03-09 09:47:53 +01:00
PascalString s = {3, '1', '0', '0'};
PascalString s2 = {4, 'f', 'f', 'f', 'f'};
println(hexStringToInt(s));
println(hexStringToInt(s2));
2018-03-16 18:03:32 +01:00
println(hexDigitToInt('D'));
println(hexDigitToInt('9'));
println(hexDigitToInt('2'));
2018-03-09 09:47:53 +01:00
return 0;
}