#include <iostream>
#include <unistd.h>
#include <stdlib.h>
void usage(char **argv);
int main(int argc, char** argv) {
int opt = 0;
int left = 0;
while ((opt = getopt(argc, argv, "hl:")) != -1) {
switch(opt) {
case 'l':
left = atoi(optarg);
break;
case 'h':
default:
usage(argv);
exit(1);
}
}
unsigned char val = 0x01;
std::cout << std::hex << " 1 << " << left << " = 0x" << (val << left) << std::endl;
return 0;
}
void usage(char **argv) {
std::cout << "Usage: " << argv[0] << "<options> \n"
<< "Options:\n"
<< "\t-h, --help\t\tShow this help message\n"
<< "\t-l, --left VALUE\tSpecify the shift left value"
<< std::endl;
}
移位验证小工具
最新推荐文章于 2022-03-11 09:52:17 发布