i hope you to debug this file.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NUM 10000
struct date
{
char NameDate[30][10];
char airfoilDate[100][10000];
}
inDate;
int index = 0;
void input();
void search();
void edit();
void list();
void main()
{
FILE *fp;
char select;
int i;
fp = fopen("test.txt","w");
if (fp == NULL)
{
printf("error.\n");
return ;
}
for(i=0; i<NUM; i++)
{
while(1)
{
printf("input: [1]\nsearch: [2]\nedit: [3]\nprintall: [4]\nexit: [0]\nyou press:");
fflush(stdin);
select = fgetc(stdin);
switch(select)
{
case '1':
input();
break;
case '2':
search();
break;
case '3':
edit();
break;
case '4':
list();
break;
case '0':
exit(0);
break;
default:
printf("error.\n");
break;
}
}
void input()
{
printf("enter airfoil code:");
scanf("%s", inDate.NameDate[index]);
printf("enter data:");
scanf("%s", inDate.airfoilDate[index]);
++index;
}
void search()
{
int i;
char sea[15];
printf("enter the airfoil code that you finding: ");
scanf("%s", sea);
for(i=0; i<index; i++)
{
if(!strcmp(sea, inDate.NameDate[i]))
{
printf("airfoil code: %s \n", inDate.NameDate[i]);
printf("data: %s \n", inDate.airfoilDate[i]);
}
}
}
void edit()
{
int i;
char re[20];
printf("enter airfoil code that you want to edit: ");
scanf("%s", re);
for(i=0; i<index; i++)
{
if(!strcmp(re, inDate.NameDate[i]))
{
printf("airfoil code: %s ", inDate.NameDate[i]);
printf("data: %s ", inDate.airfoilDate[i]);
printf("data for edit: ");
scanf("%s", inDate.airfoilDate[i]);
}
}
}
void list()
{
int i;
for(i=0; i<index; i++)
{
printf("airfoil code: %s ", inDate.NameDate[i]);
printf("data: %s ", inDate.airfoilDate[i]);
}
}
}
printf("saved.\n");
fclose(fp);
return ;
}
or please teach me how to solve this problem
Sorry, but no one is likely to help you unless you state clearly what your problem is.