#include <string.h>
#include <stdio.h>
#define CHANGE 13.7603

void atseur(void);      
int checkinput(char *input);
void eur_in_ats(void);
void ats_in_eur(void);
void my_chr_replace(char *string,char old,char new); // neu

char sChoice[100];
char sAts[100], sEuro[100];
float fAts, fEuro;

int main(void)         
{                                                       
    atseur();
}

void atseur(void)
{
    do 
    {
do
{
      printf("EURO-ATS (1) ATS-EURO (2) Beenden (3): ");
    scanf("%s",sChoice);
} while(checkchoice(sChoice));

if (sChoice[0]=='1')
        {
    eur_in_ats();
}
        else if (sChoice[0]=='2')
        { 
    ats_in_eur();
        }
    } while (sChoice[0]!='3');
}

void eur_in_ats(void)
{
    memset(sAts,0x00,100);
    memset(sEuro,0x00,100);
    do
    {
       printf ("Bitte den Betrag in EURO eingeben: ");
       scanf ("%s", sEuro);
    }while(checkinput(sEuro));
    printf ("Betrag in EUR: %s\n", sEuro);
    my_chr_replace(sEuro,',','.'); //neu
    sscanf(sEuro,"%f",&fEuro);
    fAts=fEuro*CHANGE;
    sprintf(sAts,"%f",fAts); // neu
    my_chr_replace(sAts,'.',','); // neu
    printf ("Betrag in ATS: %s\n", sAts);
}

void ats_in_eur(void)
{
    memset(sAts,0x00,100);
    memset(sEuro,0x00,100);
    do
    {
    printf ("Bitte den Betrag in ATS eingeben: ");
    scanf ("%s", sAts);             
    } while(checkinput(sAts));
    
    printf ("Betrag in ATS: %s\n", sAts);
    my_chr_replace(sAts,',','.'); //neu
    sscanf(sAts,"%f",&fAts);
    fEuro=fAts/CHANGE;
    sprintf(sEuro,"%f",fEuro); // neu
    my_chr_replace(sEuro,'.',','); // neu
    printf ("Betrag in EURO: %s\n", sEuro);
}

int checkinput(char *sEingabe)
{
        int i;
        int iAnzKomma=0;

for (i=0;i<=strlen(sEingabe)-1;i++)
{
switch (sEingabe[i])
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
continue;
                                break;
case ',':
                                iAnzKomma++;

                                if (iAnzKomma > 1)
                                {
                                   printf("Bitte geben Sie maximal ein Komma ein !\n");
   return 1; /* true */
                                }
 
continue;
break;
default:
                                printf("Bitte geben Sie nur Zahlen und optional ein Komma ein !\n"); // neu 
return 1; /* true */
   }
   }

   return 0; /* false */ 
}

int checkchoice(char *sChoice)
{
if (strlen(sChoice) != 1)
{
printf("Bitte geben Sie nur 1,2 oder 3 ein !\n");
return 1; /* true */
}

switch (sChoice[0])
{
case '1':
case '2':
case '3':
break;  
default:
printf("Bitte geben Sie nur 1,2 oder 3 ein !\n");
return 1; /* true */
}

   return 0; /* false */ 
}

void my_chr_replace(char *string,char old,char new) // neu
{
   int i;

   for (i=0;i<strlen(string);i++)
   {
      if (string[i] == old) 
         string[i] = new;
   }
}