
C语言关于文件操作
#include<stdio.h>#include<stdlib.h>#include<string.h>intsave_as(charfilename[])//保存文件...
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int save_as(char filename[]) //保存文件
{
NODE *p;
FILE *fp;
int i=0,j=0;
char str[100];
char tmpname[51];
if(filename[0]!='/') //是否根目录
{
strcpy(tmpfile,filename);
}
else
{
strcpy(tmpfile,&filename[1]); //第2个元素的地址给tmpfile
chdir("/"); //当前目录改为根目录
i=0;
do
{
if(tmpfile[i]=='/') //j组成后的新串,i是载取的位置
{
j=i;
i=0;
*(tmpfile+j)='\0'; //取出前面
if(chdir(tmpfile))
{
mkdir(tmpfile);
chdir(tmpfile);
}
strcpy(tmpfile,tmpfile+j+1);
}
i++;
}while (tmpfile[i]!='\0');
}
}
出错提示:
1.c:1338: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1342: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1347: subscripted value is neither array nor pointer
1.c:1351: invalid lvalue in assignment
1.c:1352: warning: passing arg 1 of `chdir' from incompatible pointer type
1.c:1355: warning: passing arg 1 of `chdir' from incompatible pointer type
1.c:1357: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1357: warning: passing arg 2 of `strcpy' from incompatible pointer type
1.c:1360: subscripted value is neither array nor pointer
这到底哪错了啊>?
??? 展开
#include <stdlib.h>
#include<string.h>
int save_as(char filename[]) //保存文件
{
NODE *p;
FILE *fp;
int i=0,j=0;
char str[100];
char tmpname[51];
if(filename[0]!='/') //是否根目录
{
strcpy(tmpfile,filename);
}
else
{
strcpy(tmpfile,&filename[1]); //第2个元素的地址给tmpfile
chdir("/"); //当前目录改为根目录
i=0;
do
{
if(tmpfile[i]=='/') //j组成后的新串,i是载取的位置
{
j=i;
i=0;
*(tmpfile+j)='\0'; //取出前面
if(chdir(tmpfile))
{
mkdir(tmpfile);
chdir(tmpfile);
}
strcpy(tmpfile,tmpfile+j+1);
}
i++;
}while (tmpfile[i]!='\0');
}
}
出错提示:
1.c:1338: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1342: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1347: subscripted value is neither array nor pointer
1.c:1351: invalid lvalue in assignment
1.c:1352: warning: passing arg 1 of `chdir' from incompatible pointer type
1.c:1355: warning: passing arg 1 of `chdir' from incompatible pointer type
1.c:1357: warning: passing arg 1 of `strcpy' from incompatible pointer type
1.c:1357: warning: passing arg 2 of `strcpy' from incompatible pointer type
1.c:1360: subscripted value is neither array nor pointer
这到底哪错了啊>?
??? 展开
2个回答
展开全部
subscripted value is neither array nor pointer
下标值不是数组或者指针。。。
invalid lvalue in assignment
无效左值。。。
下标值不是数组或者指针。。。
invalid lvalue in assignment
无效左值。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询