Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
In dem Fall ist es egal ob char temp = 0; oder char temp = '\0';du meinst \0 oder so hab ich das nämlich in meinem Buch gelesen.
Wenn ich das Programm mitm Debugger an geeigneter Stelle anhalte sehe ich das in der Variable der richtige Wert ist.Und was meinst du mit probleme macht die Ausgabe?
#include <stdio.h>
#include <conio.h>
int main()
{
double zahl = 0;
char eingabe[20];
char temp;
int index = 0;
while((temp = getch()) != 13)
{
if(temp == ',')
temp = '.';
printf("%c", temp);
eingabe[index++] = temp;
eingabe[index] = 0;
}
zahl = atof(eingabe);
printf("\n%f", zahl);
printf("\n%f + 1 = %f", zahl, zahl+1);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int isDouble(char* toTest){
while(*toTest){
if((*toTest < '0' || *toTest > '9') && *toTest != '.') return 0;
toTest++;
}
return 1;
}
int main()
{
char input[20];
scanf("%s", input);
if(isDouble(input)) printf("%lf\n", atof(input));
else printf("Error: Input was not valid\n");
}
#include <stdio.h>
#include <conio.h>
int main()
{
double zahl = 0;
char eingabe[20];
char temp;
int index = 0;
while((temp = getch()) != 13)
{
if(temp == ',')
temp = '.';
printf("%c", temp);
eingabe[index++] = temp;
eingabe[index] = "\0";
}
sscanf(eingabe,"%lf",&zahl);
printf("\n%lf",zahl);
getch();
return 0;
}
Einfach nur sowieso machst du bei double %f denn in meinem buch steht %lf oder lg
#include <stdio.h>
#include <conio.h>
int eingabe_double(double);
int main(void){
double cool;
printf("Bitte zahl eingeben: ");
eingabe_double(cool);
printf("\n Die Zahl war : %lf",cool);
getch();
}
int eingabe_double(double zahl)
{
char eingabe[20];
char temp;
int index = 0;
while((temp = getch()) != 13)
{
if(temp == ',')
temp = '.';
printf("%c", temp);
eingabe[index++] = temp;
eingabe[index] = "\0";
}
sscanf(eingabe,"%lf",&zahl);
//printf("\n%lf",zahl);
return 0;
}