1>delete.obj : error LNK2019: 无法解析的外部符号 "char __cdecl readfile(class

AmberPan721 2014-06-27 03:47:55
#include <iostream>
#include <windows.h>
#include <string>
#include <fstream>
#include <math.h>
#include "file_operate.h"
#include "delete.h"
using namespace std;

void refresh(int start,int end,fstream &f)//从start开始写到end
{
fstream f3;
f3.open("reftmp.txt",ios::binary|ios::out|ios::app);
char tp;
f.seekg(start,ios::beg);
for(int i=start/8; i<end/8; i++)
{
tp=readfile(f);
writefile(tp,f3);
}
f3.close();
}

void Delete()
{
char table_name[20];//buf判断数据类型缓冲
char tp;
char *str=".txt";
char tmp[30];
int i=0,w=0;
int num=0;//属性的个数
int length[10];//每个属性的长度
char name[20][20];//每个属性的名称
int start=0,end=0;
int power=0;//是否有删除的条目
tmp[i]=' ';
string cmpa,cmpb,value;
cout<<"Delete from ";
cin>>table_name;
cmpa=string(table_name);
fstream f1;
f1.open("model.txt",ios::binary|ios::in);//判断是否存在表;
o:
tmp[i]=readfile(f1);
i++;
if(f1.eof()==0)
{
while(tmp[i-1]!=',')
{
tmp[i]=readfile(f1);
i++;
}
tmp[i-1]='\0';
cmpb=string(tmp);
if(cmpa==cmpb)//表名存在
{
int nn=1;//读取逗号个数
f1.seekg(-8,ios::cur);
p:
tp=readfile(f1);//读取属性个数及每个属性长度及属性名称
if(tp!='!')
{
tp=readfile(f1);
while(tp!=',')
{
name[num][w]=tp;
w++;
tp=readfile(f1);
}
name[num][w]='\0';
w=0;
tp=readfile(f1);
while(nn<=1)
{
tp=readfile(f1);
if(tp==',')
{
nn++;
}

}
tp=readfile(f1);
length[num]=(int)tp-48;
tp=readfile(f1);
if(tp<='9'&&tp>='0')
{
length[num]=length[num]*10+((int)tp-48);
tp=readfile(f1);

if(tp<='9'&&tp>='0')
{
length[num]=length[num]*10+((int)tp-48);
}
else
{
f1.seekg(-8,ios::cur);
}
}
else
{
f1.seekg(-8,ios::cur);
}
num++;
nn=1;
goto p;
}
else
{
f1.close();
}
strcat(table_name,str);//table_name 表名
fstream f2;
f2.open(table_name,ios::binary|ios::in);
cout<<"where ";

char tiaojian1[20];
cin>>tiaojian1;//属性名
cout<<"=";
char tiaojian2[20];
cin>>tiaojian2;
string tiaojian2str=string(tiaojian2);
string tiaojian1str=string(tiaojian1);
string shuxing;
int pos=0;//第pos个属性是有用的
for(int z=0; z<num; z++)
{
shuxing=string(name[z]);
if(tiaojian1str==shuxing)//没有判断属性是否存在
{
pos=z;
break;
}
}
int sum=0;//每条数据的间隔位数
for(int z=0; z<num; z++)
{
sum=sum+length[z]*8;
}
sum=sum-length[pos]*8;
int firstpos=0;//最开始后移位数
for(int z=0; z<pos; z++)
{
firstpos=firstpos+length[z]*8;
}

f2.seekg(firstpos,ios::cur);//第一个
char tmpp[30];//属性值
string tmpstr;
int time=0;//第几条数据是应当删除的
while(1)
{
for(int z=0; z<length[pos]; z++)
{
tmpp[z]=readfile(f2);
if(tmpp[z]==' ')
{
tmpp[z]='\0';
}
tmpp[z+1]='\0';
}
time++;
tmpstr=string(tmpp);
if(tmpstr==tiaojian2str)
{
end=time*(length[pos]*8+sum);
refresh(start,end-length[pos]*8-sum,f2);
f2.seekg(end-(sum-firstpos),ios::beg);
power=1;
start=end;
}
// f2.seekg(sum-firstpos,ios::cur);
if(f2.eof()!=0)
{
if(power==0)
{
cout<<"符合条件元素不存在!"<<endl;
return;
}
else
{
f2.close();
end=(time-1)*(length[pos]*8+sum);
fstream f4;
f4.open(table_name,ios::binary|ios::in);
refresh(start,end,f4);
f4.close();
char tt[]="del ";
strcat(tt,table_name);
system(tt);
rename("reftmp.txt",table_name);
cout<<"删除完成!"<<endl;
return;
}
}
else
{
//f2.seekg(firstpos-sum,ios::cur);
}
f2.seekg(sum,ios::cur);//间隔
}

f2.close();
return;
}
else
{
tp=readfile(f1);
while(tp!='!')
{
tp=readfile(f1);
}
i=0;
goto o;
}
}
else
{
cout<<"the table is not exist."<<endl;
f1.close();
return;
}
}
1>------ 已启动生成: 项目: 数据库, 配置: Debug Win32 ------
1>delete.obj : error LNK2019: 无法解析的外部符号 "char __cdecl readfile(class std::basic_fstream<char,struct std::char_traits<char> > &)" (?readfile@@YADAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z),该符号在函数 "void __cdecl Delete(void)" (?Delete@@YAXXZ) 中被引用
1>delete.obj : error LNK2019: 无法解析的外部符号 "void __cdecl writefile(char,class std::basic_fstream<char,struct std::char_traits<char> > &)" (?writefile@@YAXDAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z),该符号在函数 "void __cdecl refresh(int,int,class std::basic_fstream<char,struct std::char_traits<char> > &)" (?refresh@@YAXHHAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z) 中被引用
1>C:\Users\Amber.Amber-PC\Desktop\Win32Project2\Debug\数据库.exe : fatal error LNK1120: 2 个无法解析的外部命令
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

各位大神。。有知道怎么整的么、、、折腾了一晚上了。。。。
...全文
370 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
AmberPan721 2014-06-27
  • 打赏
  • 举报
回复
引用 8 楼 zhao4zhong1 的回复:
少file_operate.c文件。我猜。
真的呃。。。我忘记添加这个了。。。多谢啦~~~
勤奋的小游侠 2014-06-27
  • 打赏
  • 举报
回复
引用 8 楼 zhao4zhong1 的回复:
少file_operate.c文件。我猜。
支持。这两个函数的操作没有定义 。 看起来也不像在系统的lib里面
赵4老师 2014-06-27
  • 打赏
  • 举报
回复
少file_operate.c文件。我猜。
AmberPan721 2014-06-27
  • 打赏
  • 举报
回复
引用 5 楼 zhao4zhong1 的回复:
将错误信息中出现的标识符放在google里面搜一下,看其在哪个.lib中,然后在本地硬盘上搜索该.lib,如果没有,在网上搜索相关库或模块下载安装,然后将其所在目录填写到“附加依赖库所在目录”中,将其名字添加到“附加依赖库”中,重新连接。 VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
额。。。谷歌学校里上不上啊。。。。帮下忙搜一下吧。。。。
AmberPan721 2014-06-27
  • 打赏
  • 举报
回复
引用 3 楼 jianwen0529 的回复:
没有找到函数的实现 看看依赖有没有包含lib(静态库)或者dll(动态库) 另外建议现在写程序,尽量不要使用goto
额。。。具体该怎么做。。。刚学。。不太明白。。。网上也搜了很多解决方法。。可是没看懂。。。求具体做法。。。
赵4老师 2014-06-27
  • 打赏
  • 举报
回复
将错误信息中出现的标识符放在google里面搜一下,看其在哪个.lib中,然后在本地硬盘上搜索该.lib,如果没有,在网上搜索相关库或模块下载安装,然后将其所在目录填写到“附加依赖库所在目录”中,将其名字添加到“附加依赖库”中,重新连接。 VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
caozl 2014-06-27
  • 打赏
  • 举报
回复
无法解析的外部符号 就是没有函数实现 需要CPP或者lib(静态库)里有这个函数 DLL在运行的时候才需要
幻夢之葉 2014-06-27
  • 打赏
  • 举报
回复
没有找到函数的实现 看看依赖有没有包含lib(静态库)或者dll(动态库) 另外建议现在写程序,尽量不要使用goto
AmberPan721 2014-06-27
  • 打赏
  • 举报
回复
快来个大神吧。。。。
AmberPan721 2014-06-27
  • 打赏
  • 举报
回复
以及还有这么个问题
#include <iostream>
#include <windows.h>
#include <string>
#include <fstream>
#include <math.h>
#include "file_operate.h"
#include "insert.h"
using namespace std;

void insert()
{
    char table_name[20],buff[100],buf[100];//buff输出缓冲区,buf判断数据类型缓冲
    char tp;
    char *str=".txt";
    char tmp[20];
    int i=0,w=0,pos;//pos记录插入值位置
    int num=0;//属性的个数
    int length[10];//每个属性的长度
    char type[20][20];//每个属性的类型
    char insertbuff[1000];//插入的一条数据
    char table_buff[1500][10][100];//将表读入内存
    char ttp,ttpv[100],ttpb[100];
    int data_num=0,pp=0;//数据条数
    int key=1,ss=0;//主键的序号
    fstream f7;
    f7.open("key.txt",ios::binary|ios::in);
    string inputkeystr;//输入主键的内容
    tmp[i]=' ';
    string cmpa,cmpb,value;
    cout<<"Insert into ";
    cin>>table_name;
    cmpa=string(table_name);
    tp=readfile(f7);
    string ttpbstr;
    /* while(f7.eof()==0)
     {
         cout<<readfile(f7);
     }*/

    fstream f1;
    f1.open("model.txt",ios::binary|ios::in);//判断是否存在表;
o:
    tmp[i]=readfile(f1);
    i++;
    if(f1.eof()==0)
    {
        while(tmp[i-1]!=',')
        {
            tmp[i]=readfile(f1);
            i++;
        }
        tmp[i-1]='\0';
        cmpb=string(tmp);
        if(cmpa==cmpb)//表名存在
        {
            while(f7.eof()==0)
            {
                while(tp!=',')
                {
                    if(tp=='!')
                        tp=readfile(f7);
                    ttpb[ss]=tp;
                    tp=readfile(f7);
                    ttpb[ss+1]='\0';
                    ss++;
                }
                ss=0;
                ttpbstr=string(ttpb);
                if(ttpbstr==cmpa)
                {
                    tp=readfile(f7);
                    key=(int)tp-48;
                    break;
                }
                else
                {
                    tp=readfile(f7);
                    tp=readfile(f7);
                }
            }
            f7.close();
            int nn=1;//读取逗号个数,要读连续两个读取一个int
p:
            tp=readfile(f1);//读取属性个数及每个属性长度及属性类型

            if(tp!='!')
            {
                while(nn<=1)
                {
                    tp=readfile(f1);
                    if(tp==',')
                    {
                        nn++;
                    }

                }
                tp=readfile(f1);
                while(tp!=',')
                {
                    type[num][w]=tp;
                    w++;
                    tp=readfile(f1);
                }
                w=0;
                tp=readfile(f1);
                length[num]=(int)tp-48;
                tp=readfile(f1);
                if(tp<='9'&&tp>='0')
                {
                    length[num]=length[num]*10+((int)tp-48);
                    tp=readfile(f1);

                    if(tp<='9'&&tp>='0')
                    {
                        length[num]=length[num]*10+((int)tp-48);
                    }
                    else
                    {
                        f1.seekg(-8,ios::cur);
                    }
                }
                else
                {
                    f1.seekg(-8,ios::cur);
                }
                num++;
                nn=1;
                goto p;
            }
            else
            {
                f1.close();
            }
            strcat(table_name,str);//table_name 表名
            fstream f2;
            f2.open(table_name,ios::binary|ios::in);
            while(f2.eof()==0)
            {

                for(int p=0; p<num; p++)
                {
                    for(int r=0; r<length[p]; r++)
                    {
                        ttp=readfile(f2);
                        table_buff[data_num][p][r]=ttp;
                    }
                }
                data_num++;
            }
            data_num--;
            cout<<"values ('";
            int buff_long;
            int base=0;//记录insertbuff记录到哪一位
            for(int z=0; z<num; z++)
            {
s:
                cin>>value;
                if(z==(key-1))
                {
                    inputkeystr=value;
                }
                int buf_long,q=0;
                buf_long=value.copy(buf,90);
                buf[buf_long]='\0';
                switch(type[z][0])
                {
                case 'i':
                    if(buf_long>length[z])
                    {
                        cout<<"the value is too long,it should be "<<length[z]<<" try again!"<<endl;
                        goto s;
                    }
                    while(buf[q]!='\0')
                    {
                        if(buf[q]<'0'||buf[q]>'9')
                        {
                            cout<<"the value is wrong type! the type should be "<<type[z]<<" try again!"<<endl;
                            goto s;
                        }
                        q++;
                    }
                    break;
                case 'v':
                    if(buf_long>length[z])
                    {
                        cout<<"the value is too long,it should be "<<length[z]<<" try again!"<<endl;
                        goto s;
                    }
                    break;
                case 'd':
                    buf_long=value.copy(buf,90);
                    buf[buf_long]='\0';
                    if(buf_long!=length[z])
                    {
                        cout<<"the value's length is wrong,it should be "<<length[z]<<" try again!"<<endl;
                        goto s;
                    }
                    while(buf[q]!='\0')
                    {
                        if(buf[q]<'0'||buf[q]>'9')
                        {
                            cout<<"the value is wrong type! the type should be "<<type[z]<<" try again!"<<endl;
                            goto s;
                        }
                        q++;
                        if(q>8)
                        {
                            cout<<"the value is wrong type! the type should be "<<type[z]<<" try again!"<<endl;
                            goto s;
                        }
                    }
                    break;
                }
                string strtmp;
                for(int j=0; j<length[z]-value.size(); j++)
                {
                    strtmp=strtmp+" ";
                }
                value=value+strtmp;
                buff_long = value.copy(buff, 90);
                buff[buff_long] = '\0';
                for(pp=0; pp<=buff_long; pp++)
                    insertbuff[base+pp]=buff[pp];
                base=base+pp-1;
                string ttpp;
                if(z==(num-1))
                {
                    pos=data_num;
                    for(int i=0; i<data_num; i++)
                    {
                        for(int j=0; j<length[key-1]; j++)
                        {
                            if(table_buff[i][key-1][j]!=' ')
                            {
                                 ttpv[j]=table_buff[i][key-1][j];
                                 ttpv[j+1]='\0';
                            }

                        }
                        ttpp=string(ttpv);
                        if(ttpp==inputkeystr)
                        {
                            cout<<"主键重复!请重试!"<<endl;
                            return;
                        }
                        if(ttpp>inputkeystr)
                        {
                            pos=i;
                            break;
                        }
                    }
                    f2.close();
                    fstream f6;
                    f6.open(table_name,ios::binary|ios::out);
                    for(int t=0; t<pos; t++)
                    {
                        for(int y=0; y<num; y++)
                        {
                            for(int u=0; u<length[y]; u++)
                            {
                                writefile(table_buff[t][y][u],f6);
                            }
                        }
                    }
                    for(int t=0; t<base; t++)
                    {
                        writefile(insertbuff[t],f6);
                    }
                    for(int t=pos; t<data_num; t++)
                    {
                        for(int y=0; y<num; y++)
                        {
                            for(int u=0; u<length[y]; u++)
                            {
                                writefile(table_buff[t][y][u],f6);
                            }
                        }
                    }
                    cout<<"')"<<endl<<"插入成功"<<endl;
                }

                else
                    cout<<"','";
            }
            f2.close();
            return;
        }
        else
        {
            tp=readfile(f1);
            while(tp!='!')
            {
                tp=readfile(f1);
            }
            i=0;
            goto o;
        }
    }
    else
    {
        cout<<"the table is not exist."<<endl;
        f1.close();
        return;
    }
}
1>insert.obj : error LNK2001: 无法解析的外部符号 "char __cdecl readfile(class std::basic_fstream<char,struct std::char_traits<char> > &)" (?readfile@@YADAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z)
1>insert.obj : error LNK2001: 无法解析的外部符号 "void __cdecl writefile(char,class std::basic_fstream<char,struct std::char_traits<char> > &)" (?writefile@@YAXDAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z)

65,190

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧