题解 | #明明的随机数#
进制转换
http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
#include <stdio.h>
#include <string.h>
int main()
{
char str[1024] = {0};
int store = 0;
char *end;
while (NULL != fgets(str, sizeof(str), stdin)) {
if (str[0] == '0' && str[1] == 'x') {
store = strtol(str+2, end, 16);
printf("%d\n", store);
}
memset(str, 0 , sizeof(str));
}
return 0;
}
#include <string.h>
int main()
{
char str[1024] = {0};
int store = 0;
char *end;
while (NULL != fgets(str, sizeof(str), stdin)) {
if (str[0] == '0' && str[1] == 'x') {
store = strtol(str+2, end, 16);
printf("%d\n", store);
}
memset(str, 0 , sizeof(str));
}
return 0;
}