Question: Write a C program which: 1 . Takes command - line arguments representing unsigned integers in decimal, octal ( 0 . . . ) ,
Write a C program which:
Takes commandline arguments representing unsigned integers in decimal, octal
hex x or binary b formats.
Uses strtoul to convert to unsigned int.
Note that using base strtoul will recognize decimal, octal, and hex formats, but not
binary. To convert from binary format use base and skip the b part, eg char e;
unsigned long int xl strtoul&e; will set xl to and e will be
Displays an error message for bad arguments.
Displays the value in decimal, hex, and binary.
Displays the bitreversed value in decimal, hex, and binary.
Assume that unsigned int uses bits.
To check for strtoul failure, #include and before calling strtoul
set errno; then after calling strtoul if errno is not zero call perror strtoul; For other
bad arguments print an error message to standard error, ie fprintf stderr, "format...", ;
Test with some good arguments: xb
Sample run:
$ bits xabcefg b
xxb
bitrev xcb
convert: bad argument: abcefg
abcefg xb b
bitrev xdeb
bxbb
ECE
Operating Systems
bitrev xcdb
$
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
