警告 assignment makes integer from pointer without a cast是怎么回事
写了一个函数
void get_time(long* ptime)
{
char buff[4096+1];
int len , i ;
char* pstr;
FILE* fp;
fp=NULL;
fp=fopen("/proc/stat","r");
if(fp !=NULL)
{
len = fread(buff,sizeof(char),sizeof(buff)-1,fp);
fclose(fp);
}else
{
fclose(fp);
}
buff[len] ="\0";
pstr=sko_token(buff);
for(i = 0 ; i < PNUM ; i++)
{
ptime[i] = strtoul(pstr,&pstr,0);
}
}
编译的时候就出现警告信息:assignment makes integer from pointer without a cast
因该是这段ptime[i] = strtoul(pstr,&pstr,0);出错了,但应该怎么改才不会啊.
------解决方案--------------------
buff[len] ="\0"; 不对,用单引号。