hello shabab
shabab i'm really working in my programme and this is my event code
plzzzz help me in any problem
كود:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
void search_account(char keyname[] , char name[] , int acc_num[])
{
int i;
while(i<2 && name[i]!=keyname)
{
if(name[i]==keyname)
printf("The account number is %d" , acc_num[i]);
else
printf("Not found");
}
}
void search_month(int keymonth, int acc_num[],float monthly_balance[])
{
int i;
for(i=0;i<2;i++)
{
if(keymonth==acc_num[i])
printf("The monthly balance is %f" , monthly_balance[i]);
else printf("Not found ");
}
}
FILE add(FILE *input)
{
int newaccount;
float newbalance;
char newname[20];
printf("\n Enter the name : ");
gets(newname);
printf("\n Enter the account number : ");
scanf("%d" , &newaccount);
printf("\n Enter the monthly balance : ");
scanf("%f" , &newbalance);
fprintf(input , "%s \n%d \n%f " , gets(newname) , newaccount , newbalance);
}
main()
{
FILE *input;
int i , acc_num[20] , choice,keymonth;
float monthly_balance[20];
char name[20],keyname[20],test[20];
input=fopen("accounts.txt" , "w+r");
while(fscanf(input , "%s" , test)!=EOF)
{
{
if(isalnum(fscanf(input , "%s" , test))==1)
name[i]=fscanf(input , "%s" , test);
else if(fscanf(input , "%s" , test)>1)
acc_num[i]=fscanf(input , "%s" , test);
else
monthly_balance[i]=fscanf(input , "%s" , test);
}
i++;
}
printf("\n\n\nchoose one of the following menu please : \n\n\n");
printf("1- Find the account number (You have to enter the name) \n \n");
printf("2- Find the monthly balance in Riyals (You have to enter the account number) \n \n");
printf("3- Add a new customer \n \n");
printf("4- Display sorted lists \n \n");
printf("5- Quit \n \n \n \t");
printf("Enter your choice here ((the number)) : ");
scanf("%d" , &choice);
switch (choice)
{
case 1:
{
printf("\n\n Enter the name of the account you are looking for : ");
scanf("%s" , keyname);
search_account(keyname,name,acc_num);
}
break;
case 2 :
{
printf("\n\nEnter the account number of the monthly balance you are looking for : ");
scanf("%d" , &keymonth);
search_month(keymonth,acc_num,monthly_balance);
}
case 3 :
{
add(& *input);
break ;
default :
printf("\n\n********\n\t{{{ This is the end of the programme ..... thanx for using it :) }}}");
exit(1);
}
fclose(input);
}
plzzzzzzz i need to complete this programme my Q in previous page