Is there anyway that i can read an octal code then covert it to character ??
like if i key in '\012' it will read as '\n' ???
if i key in '141' it will read as 'a' ???
Is there anyway that i can read an octal code then covert it to character ??
like if i key in '\012' it will read as '\n' ???
if i key in '141' it will read as 'a' ???
Lots of ways
If you use the %i mode in say scanf(), then any integers you type in with a leading 0 are octal
012
0141
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I couldnt use scanf as the parameter is being pass in as a string.
coz when i read the argument it is in string format. what the function does is it read the \012 and store it in argv[1] and then pass it to convertOctal function so that it is able to convert the numbers to a character and then only store it in a variable.
Code:main(int argc, char *argv[]) { convertOctal(argv[1]); }
So use sscanf() then
Or strtol() with the base set to 8
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.