السلا م عليكم
بعد تعب شديد قمت بانجاز هذا البرنامج وعندما قمت بتشغيله
ظهرت لدي مشكلة صغيرة وهي ان البرنامج يهنق
ارجو منكم الاطلاع عليه واخباري بالخطأ
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<stdlib.h>
FILE *input;
int i=0;
char fullnames[10][30];
int account[10];
double balance[10];
/************FUNCTION TO FIND THE ACCOUNT NUMBER*******************/
void find_account(char namex[30],char fullnames[10][30],int account[10])
{
int z;
for(z=0;z<10;z++)
{
if(strcmp(fullnames[z],namex)==0)
{
printf("The account number of %s is %d",namex,account[z]);
}
}
}
/************FUNCTION TO FIND THE BALANCE NUMBER*******************/
void find_balance(int acc,int account[10],double balance[10])
{
int z;
for(z=0;z<10;z++)
{
if(account[z]==acc)
{
printf("The balance number of the account number %d is>>> %.21lf",acc,balance[z]);
}
}
}
/************FUNCTION TO ADD NEW ACCOUNT NUMBER*******************/
void add_new(char n[30],int acc,double ball)
{
fprintf(input,"%s",n);
fprintf(input,"%d\n",acc);
fprintf(input,"%.21lf\n",ball);
}
/**********************FUNCTION TO PRINT*************************/
void toprint(int choice2,char fullnames[10][30],int account[10],double balance[10])
{
int x;
switch (choice2)
{
case 1:
printf("The names are:\n");
for(x=0;x<i-1;x++)
{
printf("%s\n",fullnames[x]);
}
break;
case 2:
for(x=0;x<10;x++)
{
printf("The account number of %s is: %d\n",fullnames[x],account[x]);
}
break;
case 3:
for(x=0;x<10;x++)
{
printf("The balance number of %s is: %.21lf\n",balance[x]);
}
break;
}
}
/****************************************************/
/*******************MAIN FUNCTION********************/
/****************************************************/
void main(void)
{
int choice1,g,z,acc,ch,newacc;
double newbal;
char c,newname[30],name[30];
while(!feof(input))
{
fscanf(input,"%s\n%d\n%lf",fullnames,&account,&balance);
i++;
}
for(g=0;g<i;g++)
{
for(z=0;z<30;z++)
{
c= fullnames[g][z];
if(c=='_')
{
fullnames[g][z] = ' ';
}
}
}
printf("1.Find the account number (given the name)\n");
printf("2.Find the monthly balance in Riyals (given the account number)\n");
printf("3.Add a new customer (i.e. a new account)\n");
printf("4.Display sorted lists of account numbers, names or balances (according to user's section)\n");
printf("5.Quit\n");
printf("Choose one of the options above by enter the number of your choice and the press ENTER\n");
scanf("%d",&choice1);
switch (choice1)
{
case 1:
printf("Enter the name to get account number\n");
gets(name);
find_account(name,fullnames,account);
break;
case 2:
printf("Enter the account to get balance number\n");
scanf("%d",&acc);
find_balance(acc,account,balance);
break;
case 3:
printf("Enter new name to be stored\n");
gets(newname);
printf("Enter its account number to be stored\n");
scanf("%d",&newacc);
printf("Enter its balance to be stored\n");
scanf("%lf",&newbal);
add_new(newname,newacc,newbal);
break;
case 4:
printf("Choose 1 if want to print all the names or 2 to print the account numbers or 3 to print the balance and then press ENTER\n");
scanf("%d",&ch);
toprint(ch,fullnames,account,balance);
break;
case 5:
exit(1);
break;
default:
while(i<1||i>5)
{
printf("Sorry,Wrong\nEnter the number of your choice between 1-5\n");
scanf("%d",&ch);
}
}
}