Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- int main()
- {
- char str[100],*p,*po;
- long long int a;
- for( ; ; ){
- scanf("%s",str);
- if(str[0]=='-'){
- break;
- }
- p=&str;
- if(str[0]=='0'&&str[1]=='x'){
- p+=2;
- a=strtol(p,&po,16);
- printf("%lld\n",a);
- }
- else{
- a=strtol(p,&po,10);
- printf("0x%X\n",a);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement