warning: assignment makes pointer from integer without a cast

编译的时候报警告:warning: assignment makes pointer from integer without a cast

出现这个警告的原因是在使用函数之前没有对函数进行声明,未经声明的函数原型一律默认为返回int值。

这样、就相当于你调用了返回值为int的函数,并将其赋给了char*变量,所有会出现警告。


warning: assignment makes pointer from integer without a cast

warning: assignment makes pointer from integer without a cast

阅读更多

warning assignment makes pointer from integer without a cast错误

03-12

warning assignment makes pointer from integer without a cast错误,共三个错误,错误行分别是24,25,26(代码中有标示)请大家帮忙 谢谢啦!!!rnrn在linux下编译c程序提示以上错误,源代码如下rnrn#include rn#include rn#include rn#include rn#include rnrn#define POS_SIZE 500000rn#define MAX_WORD_LENGTH 500000rnrnint main(int argc, char* argv[])rnrn FILE *fin, *fout,*fIndexEntry;rn char *buf; /* buffer holding records */rn char *endPtr;rn int i,docCount;rn unsigned long long address=0;rn rn buf = (char *) malloc(POS_SIZE);rn char *bufPtr=buf;rn char *current = (char *)malloc(MAX_WORD_LENGTH);rn char *previous = (char *)malloc(MAX_WORD_LENGTH);rn char *addr= (char *)malloc(sizeof(unsigned long long));rn rn fin = fopen64("./sortedPosting", "r");//////////////24行rn fout = fopen64("./invertedIndex", "w");rn fIndexEntry = fopen64("./IndexEntry", "w");rn docCount=1;rn i=0;rn while (!feof(fin))rn rn rn if(fgets(buf,POS_SIZE,fin)==NULL)rn break;rn bufPtr = strstr(buf," ");rn if(bufPtr == NULL)rn continue;rn if(*buf==' ')rn continue;rn elsern rn printf("sdf\n"); rn i++;rn if(i==3)rn break;rn rn rnrn while (!feof(fin))rn rn memset(buf,'\0',POS_SIZE);rn if(fgets(buf,POS_SIZE,fin)==NULL)rn break;rn bufPtr = strstr(buf," ");rn if(bufPtr == NULL)rn continue;rn if(*buf==' ')rn continue; rnrn endPtr=strstr(bufPtr,"\n");rn if(endPtr==NULL)rn continue;rn else if(*(endPtr-1)==' ')rn endPtr=endPtr-1;rn rn rn memset(current,'\0',MAX_WORD_LENGTH);rn memcpy(current,buf,bufPtr-buf);rnrn if(strcmp(previous,current)==0)rn rn rn fwrite(bufPtr+1,endPtr-bufPtr-1,1,fout);rn fwrite(" ",1,1,fout);rn address+=endPtr-bufPtr;rn docCount++;rn rn elsern rn if(address!=0)rn rn memset(addr,'\0',sizeof(addr));rn sprintf(addr,"%d",docCount);rn fwrite(addr,strlen(addr),1,fIndexEntry);rn fwrite("\n",strlen("\n"),1,fIndexEntry);rn fwrite("\n",strlen("\n"),1,fout);rn address+=strlen("\n");rn docCount=1;rn rn fwrite(buf,bufPtr-buf,1,fIndexEntry);rn fwrite(" ",1,1,fIndexEntry);rn memset(addr,'\0',sizeof(addr));rn sprintf(addr,"%llu",address);rn fwrite(addr,strlen(addr),1,fIndexEntry);rn fwrite(" ",1,1,fIndexEntry);rn fwrite(buf,endPtr-buf-1,1,fout);fwrite(" ",1,1,fout);rn address+=endPtr-buf;rn memset(previous,'\0',MAX_WORD_LENGTH);rn strcpy(previous,current);rn rn rn rn rn fclose(fIndexEntry);rn fclose(fin);rn fclose(fout);rn free(buf);rnrnrn

没有更多推荐了,返回首页