I am trying to make a hexadecimal string converter. I want the argument to be passed at startup. While I have it.
int main(int argc, const char *argv[]){
int i;
for (i=0; i < strlen(argv[1]); i++) {
printf("%s = %c\n",argv[1], (int)atol(argv[i]));
}
return 0;
}
but in printf()- argv[i]refer to all lines from this run. (ex "HexToString.exe", "ABCDEF0123456789"), but what I'm trying to do applies to all characters in the second argument, so `argv [1] [4] = 'E', but I don't think I can put the second bracket there, because its a one-dimensional array, it did not work before when I tested it.
The output, and it may seem strange, I want to be the equivalent of an ascii hex value. example. 'B' is 11, and ascii 11 is ♂.
So, I think im really trying to do exactly that ^ here, but with a string of these values. I know that this will not work as it is now (it will read them two characters at a time, convert and output), but for now I just want to be able to convert individual characters at a time.
double parentheses are also compiled, but an error after execution.
source
share