#include "stdafx.h"
#include "stdio.h"
#include "malloc.h"
#define LEN sizeof(struct student)
#define NULL 0
int n=0;
char menu()
{
int i;
for (i=0;i<42;i++)
{
printf("*");
}
printf("\n");
printf("* Tiny In-Mem DataBase version 0.1 *\n");
printf("* Copyright aaa All Rights Reserved *\n");
for (i=0;i<42;i++)
{
printf("*");
}
printf("\n");
printf("DBI=>");
return 0;
}
struct student
{
char column_name;
char datatype;
char nullor;
struct student *next;
}stu[];
struct student *create(void)
{
struct student *head;
struct student *p1,*p2;
int i;
char ch;
FILE *fp;
fp=fopen("c:\\create.txt","r");
ch=fgetc(fp);
while (ch!=EOF)
{
ch=fgetc(fp);
if(ch==';')
{
n=n+1;
}
}
rewind(fp);
while (ch!='(')
{
ch=fgetc(fp);
}
if (ch=='(')
{
ch=fgetc(fp);
p1=p2=( struct student *)malloc(LEN);
fscanf(fp,"%s %s %s",&p1->column_name,&p1->datatype,&p1->nullor);
ch=fgetc(fp);
while (ch!=';')
{
ch=fgetc(fp);
}
for(i=1;i<=n;i++)
{
if(i==1)
{
head =p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct student *)malloc(LEN);
fscanf(fp,"%s %s %s",&p1->column_name,&p1->datatype,&p1->nullor);
ch=fgetc(fp);
}
p2->next=NULL;
}
fclose(fp);
printf("\n");
printf("---Create Table Completed!---");
return(head);
}
void load()
{
char ch;
FILE *fp;
fp=fopen("c:\\data.txt","r");
ch=fgetc(fp);
while (ch!=EOF)
{
ch=fgetc(fp);
if(ch==',')
{
n=n+1;
}
}
rewind(fp);
int i;
for (i=0;i<=(n/2);i++)
{
ch=fgetc(fp);
fread("c:\\data.txt",sizeof(struct student),1,fp);
fwrite(&stu[i],sizeof(struct student),1,fp);
}
printf("\n");
printf("---Import Sata Completed!---");
printf("---%d Records Imported Successfully---",n/2);
fclose(fp);
}
void help()
{
printf("-c 文件路径名:表示根据指定位置的文件内语句建立一个数据库表;\n");
printf("-i 数据库名 数据文件路径名:表示从制定文本文件中导入数据到数据库的表中;\n");
printf("-s 文件路径名:表示从指定文本文件中读取语句执行查询操作;\n");
printf("-u 文件路径名:表示从指定文本文件中读取语句执行更新操作;\n");
printf("-d 文件路径名:表示从指定文本文件中读取语句执行删除操作;\n");
printf("-h 帮助信息,提示各个参数的格式和含义\n");
printf("-q 退出程序;\n");
}
void quit()
{
printf("\n");
printf("---Bye!---");
}
int main(int argc, char* argv[])
{
menu();
char b[50];
char *p;
p=b;
scanf("%s",p);
p++;
struct student *head;
switch(*p)
{
case 'c': create();break;
case 'i': load();break;
case 'h': help();break;
default: printf("error\n");break;
case 'q': quit();
}
return 0;
}
显示064087.obj : error LNK2001: unresolved external symbol "struct student * stu" (?stu@@3PAUstudent@@A)
Debug/064087.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
这是什么错误,怎么修改啊