逐行读取文件的16进制地址数据并按地址(16进制)显示

range.txt 

0x40057e
0x400598
#include<stdio.h>
int main()
{
    char s1[10]={0};
    char s2[10]={0};
  
    int i=0;
    FILE *fp=open("range.txt","r");
    fscanf(fp,"%s",s1);
    fscanf(fp,"%s",s2);
    printf("%s\n%s\n",s1,s2);

    //把字符串转换成16进制
    uint64_t from_addr= (uint64_t) strtol(s1, NULL, 16);
    uint64_t to_addr= (uint64_t) strtol(s2, NULL, 16);

    fclose(fp);
    return 0;
}

 

 

上一篇:XV6学习(9)Lab cow: Copy-on-write fork


下一篇:自定义哈希