转换字符串成INT64

可能这个问题好多人碰到过.

u_int64_t PktRx=0,PktTx=0;

    if(strstr(msg,"rcv")!=0)
        {
          if(sscanf(msg, "/tPacket rcv    : %lld/n", &PktRx) == -1)
               {
                 continue;
         }
        //  printf("PktRx:%lld/n",PktRx);
        }

 

 

+++++++++++++++++++++++++++++++++++++++++

 

u_int32_t immSysUpTime()
{
    FILE *fp;
    u_int64_t uptime;

    if ((fp = fopen ("/proc/uptime", "r")) != NULL) {
 
        if (!fscanf(fp, "%lld", &uptime)) {
     uptime = 0;
        }
 
        fclose(fp);
    }

    return (u_int32_t)(0xffffffffLL & uptime);  // snmp uptime is only 32bit
}

 

你可能感兴趣的:(File,null,FP)