Added simple implementation of hex/octal conversion
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -d "bin" ]; then
|
||||
mkdir bin
|
||||
echo "Created bin directory"
|
||||
fi
|
||||
|
||||
current_dir=`pwd`
|
||||
hex_octal_conv_lib_root_dir="../../libraries/hex_octal_conv"
|
||||
hex_octal_conv_lib_include_dir="$hex_octal_conv_lib_root_dir/include"
|
||||
hex_octal_conv_lib_dir="$hex_octal_conv_lib_root_dir/bin/static"
|
||||
|
||||
gcc -c main.c -I"$hex_octal_conv_lib_include_dir" -o bin/main.o -O3
|
||||
|
||||
cd $hex_octal_conv_lib_root_dir
|
||||
./compile.sh "release"
|
||||
cd $current_dir
|
||||
|
||||
gcc bin/main.o -L"$hex_octal_conv_lib_dir" -lhexoctalconv -o bin/a.out -O3
|
||||
@@ -10,8 +10,39 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hex.h"
|
||||
|
||||
void test();
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void test()
|
||||
{
|
||||
char *number = "21";
|
||||
char hex_number[1024];
|
||||
|
||||
HexOctalConv_number_converted_to_hex(hex_number, number);
|
||||
|
||||
printf("%s converted to hex is %s\n", number, hex_number);
|
||||
|
||||
number = "55";
|
||||
HexOctalConv_number_converted_to_hex(hex_number, number);
|
||||
printf("%s converted to hex is %s\n", number, hex_number);
|
||||
|
||||
const int numerical_value = HexOctalConv_hex_converted_to_number(hex_number);
|
||||
printf("Hexidecimal %s is %d\n", hex_number, numerical_value);
|
||||
|
||||
char octal_number[1024];
|
||||
HexOctalConv_number_converted_to_octal(octal_number, number);
|
||||
printf("%s converted to octal is %s\n", number, octal_number);
|
||||
|
||||
const int o_numberical_value = HexOctalConv_octal_converted_to_number(octal_number);
|
||||
printf("Octal %s converted to a numerical value is %d\n", octal_number, o_numberical_value);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user