Hi everybody,

I have create the following program:


Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int menu(void);
void enter_invoice();
void display_invoice();
void total_amount();
int elegxos (int s[9]);

struct apodeixi {
	int afm[9];
	float poso;
	} katalogos[10];

int elegxos (int s[9]) 
{
	int athrafm,ypolafm;
	
	athrafm=(256*s[0])+(128*s[1])+(64*s[2])+(32*s[3])+(16*s[4])+(8*s[5])+(4*s[6])+(2*s[7]); 
	ypolafm=athrafm%11; 

	if ((ypolafm%10)==s[8])
	{ 
	return 1; 
		} 
	else 
	return 0; 
} 


int main(void)
{
	int choice;
	do {
		choice = menu();
		switch(choice) {
		case 1: enter_invoice(); /* Eisagogi apodeikseon */
			break;
		case 2: display_invoice(); /* Emfanisi apodeikseon */ 
			break;
		case 3: total_amount(); /* Emfanisi Sinolikou Posou */
			break;
						}
	} while(choice!=4);
return(0);
}

menu(void)
{
	int choice;

	printf ("Make a choice from the menu:\n");
	printf ("	1. Enter Invoice\n");
	printf ("	2. Display Invoices\n");
	printf ("	3. Total Amount of the Invoices\n");
	printf ("	4. Quit\n\n");
	
	do {
		printf ("Make a choice: ");
		scanf ("%d", &choice);
	} while (choice<1 || choice>4);

	return choice;
}


void enter_invoice(void)
{
	int  i, j, s[9];
	j = 0;


	for(i=1; i<=10; i++) 
	{
		printf("Please enter AFM\n");
		
			for(j=0; j<9; j++)

				do {
					printf(" %d digit from AFM: ",j+1); 
					scanf ("%d",&s[j]); 
				}	while ((s[j]<0 || s[j]>9)); 
				
				if (elegxos(s)==1) 
				{
					printf(" The AFM is Valid \n");
						for(j=0;j<9;j++)
							katalogos[i].afm[j] = s[j];
					}
				 
				else if(elegxos(s)==0)
				{
							printf(" \nThe AFM is not Valid. Please re-Enter the AFM\n"); 
							continue;}
						
					printf("Please enter the amount: ");
					scanf("%f", &katalogos[i].poso);	
					break;
	} 
 }

void display_invoice(void)
{
	int i, j;
	
	for (i=1; i<=10; i++)
	{
		printf("The %d AFM:  ",i);
		for (j=0; j<9; j++)
		{ 
			printf("%d", katalogos[i].afm[j]);
		}
		printf(" The Amount is: %f\n",  katalogos[i].poso);
	}

}

void total_amount(void)
{
	int i;
	float sum;
	
	sum=0;

	for (i=1; i<10; i++)
	{
		sum +=katalogos[i].poso;
	}
	printf("The total amount of the invoices is: %f\n", sum);
}
A valid AFM is 122635660

And I have several problems:
a) When everytime I press 1 and start entry numbers the already registered numbers delete and the data entry begins from the start
b) When I make a wrong entry the program take me to the next line of the table
c) and last but not least, when I press a char in the menu the whole program stucks.

Thanx in advance