lzf0112 发表于 2006-12-25 21:47

[求助]assignment makes pointer from integer without a cast

<P>#include "stdio.h"<BR>#include "filesys.h"<BR>unsigned int read(user_id,fd_1,buf,size)<BR>unsigned int user_id;<BR>int fd_1;<BR>char *buf;<BR>unsigned int size;<BR>{<BR>unsigned long off;<BR>int block,block_off,i,j,k;<BR>struct inode *inode;<BR>char temp_buf[size];<BR>char *temp;</P>
<P>temp = temp_buf;</P>
<P>for(j=0;j&lt;USERNUM;j++)<BR>     if(user[j].u_uid == user_id)<BR>     {<BR>       k=j;<BR>       break;<BR>     }</P>
<P><BR>inode=sys_ofile[user[k].u_ofile[fd_1]].f_inode;<BR>if(!(sys_ofile[user[k].u_ofile[fd_1]].f_flag&amp;FREAD))<BR>          {  printf("\n the file is not opened for read\n");<BR>             return 0;<BR>           }</P>
<P>off=sys_ofile[user[k].u_ofile[fd_1]].f_off;<BR>if((off+size)&gt;inode-&gt;di_size)<BR>size=inode-&gt;di_size-off;<BR>block_off=off%BLOCKSIZ;<BR>block=off/BLOCKSIZ;<BR>if(block_off+size&lt;BLOCKSIZ)<BR>         {<BR>        fseek(fd,DATASTART+inode-&gt;di_addr[block]*BLOCKSIZ+block_off,SEEK_SET);<BR>            fread(buf,1,size,fd);<BR>            sys_ofile[user[k].u_ofile[fd_1]].f_off+=size;//记录文件读写指针现在的偏移<BR>        return size;<BR>          }</P>
<P>fseek(fd,DATASTART+ inode-&gt;di_addr[block]*BLOCKSIZ+block_off,SEEK_SET);<BR>fread(temp,1,BLOCKSIZ-block_off,fd);<BR>temp+=BLOCKSIZ-block_off;</P>
<P>for(i=0;i&lt;(size-(BLOCKSIZ-block_off))/BLOCKSIZ;i++)<BR>         {<BR>         fseek(fd,DATASTART+inode-&gt;di_addr[block+1+i]*BLOCKSIZ,SEEK_SET);<BR>             fread(temp,1,BLOCKSIZ,fd);<BR>             temp+=BLOCKSIZ;<BR>          }<BR>block_off=(size-block_off)%BLOCKSIZ;  //读最后一块<BR>block=inode-&gt;di_addr[size/BLOCKSIZ+1];<BR>fseek(fd,DATASTART+block*BLOCKSIZ,SEEK_SET);<BR>fread(temp,1,block_off,fd);<BR>sys_ofile[user[k].u_ofile[fd_1]].f_off+=size;</P>
<P>memcpy(buf,temp_buf,size);<BR>return size;<BR>}</P>
<P>编译时提示:assignment   makes   pointer   from   integer   without   a   cast<BR>各为帮忙看一下啊。。。</P>

lzf0112 发表于 2006-12-26 16:44

路过的帮忙解决一下啊。。。。。。

页: [1]

编程论坛