This is a piece of code that I can't seem to get right. Hehe.
I've initialized the string "sym" to have the values '0' and '0'. I then call the function "cnvrt" and use "sym" in the parameter(not so sure if that's the right term) of "cnvrt". Since strings are passed by reference, the value of "sym" after I put it in "cnvrt" should be ' ' and '\0'; at least that's what I think.
That is why I need help on this one. It's part of my machine problem and I really have to finish it. Tnx a lot..
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void cnvrt(char s_Hex1[2])
{
char s_Hexdecitable[16][6] = {{' ', '0', '@', 'P', '`', 'p'},
{'!', '1', 'A', 'Q', 'a', 'q'},
{'"', '2', 'B', 'R', 'b', 'r'},
{'#', '3', 'C', 'S', 'c', 's'},
{'$', '4', 'D', 'T', 'd', 't'},
{'%', '5', 'E', 'U', 'e', 'u'},
{'&', '6', 'F', 'V', 'f', 'v'},
{'\'', '7', 'G', 'W', 'g', 'w'},
{'(', '8', 'H', 'X', 'h', 'x'},
{')', '9', 'I', 'Y', 'i', 'y'},
{'*', ':', 'J', 'Z', 'j', 'z'},
{'+', ';', 'K', '[', 'k', '{'},
{',', '<', 'L', '\\', 'l', '|'},
{'-', '=', 'M', ']', 'm', '}'},
{'.', '>', 'N', '^', 'n', '~'},
{'/', '?', 'O', '_', 'o', ' '}};
char row, col;
row = s_Hex1[1];
col = s_Hex1[0] - 2;
switch(row){
case 'A':{
row = 9;
break;
}
case 'B':{
row = 10;
break;
}
case 'C':{
row = 11;
break;
}
case 'D':{
row = 12;
break;
}
case 'E':{
row = 13;
break;
}
case 'F':{
row = 14;
break;
}
}
s_Hex1[0] = s_Hexdecitable[row][col];
s_Hex1[1] = '\0';
}
int main()
{
char sym[2] = {'0', '0'};
cnvrt(sym);
return 0;
}