bugfix
parent
4d10d38676
commit
abc0cb0671
|
@ -1,4 +1,5 @@
|
|||
#include "Funktion_Flugi.h"
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int quiz(char Question[][500], char Answer[], int zahl_h) {
|
||||
|
@ -131,14 +132,27 @@ int Flugi() {
|
|||
// Read lines from the file
|
||||
while (fgets(lines[line_count], MaxLength, file) != NULL) {
|
||||
size_t len = strlen(lines[line_count]);
|
||||
if (len > 0 && lines[line_count][len - 1] == '\n') {
|
||||
lines[line_count][len - 1] = '\0'; // Entferne das '\n'
|
||||
len--;
|
||||
if (len <= 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (lines[line_count][len - 1] == '\n') {
|
||||
lines[line_count][len - 1] = '\0'; // Entferne das '\n'
|
||||
len--;
|
||||
}
|
||||
#else
|
||||
if (lines[line_count][len - 1] == '\n') {
|
||||
lines[line_count][len - 1] = '\0'; // Entferne das '\n'
|
||||
len -= 3;
|
||||
} else {
|
||||
len -= 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Frage und Antwort trennen
|
||||
if (len > 2) {
|
||||
Answer[line_count] = lines[line_count][len - 1]; // Letztes Zeichen als Antwort
|
||||
if (1) {
|
||||
Answer[line_count] = lines[line_count][len]; // Letztes Zeichen als Antwort
|
||||
lines[line_count][len - 2] = '\0'; // Kürze Frage um Antwortzeichen
|
||||
strcpy(Question[line_count], lines[line_count]);
|
||||
}
|
||||
|
@ -152,17 +166,15 @@ int Flugi() {
|
|||
// close file
|
||||
fclose(file);
|
||||
|
||||
/*
|
||||
// Output
|
||||
printf("\nDie Datei wurde in %d Zeilen eingelesen:\n", line_count);
|
||||
for (int i = 0; i < line_count; i++) {
|
||||
printf("Zeile %d: %s\n", i + 1, Question[i]);
|
||||
size_t len = strlen(lines[i]);
|
||||
printf("Antwort: %c\n", Answer[i]);
|
||||
|
||||
|
||||
if (0){
|
||||
// Output
|
||||
printf("\nDie Datei wurde in %d Zeilen eingelesen:\n", line_count);
|
||||
for (int i = 0; i < line_count; i++) {
|
||||
printf("Zeile %d: %s\n", i + 1, Question[i]);
|
||||
size_t len = strlen(lines[i]);
|
||||
printf("Antwort: %c\n", Answer[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//char question[2][50]; //= {"Schaffen wir das? (1 = Ja, 0 = Nein)", "Wie geht das? (1 = Einfach, 0 = Schwer)"};
|
||||
//int answer[2] = {1, 0};
|
||||
|
@ -181,12 +193,14 @@ int Flugi() {
|
|||
// Ergebnisse ausgeben
|
||||
print_results(zahl_h, wrong_questions);
|
||||
|
||||
return 0;
|
||||
|
||||
usleep(2000000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int main()
|
||||
{
|
||||
Flugi();
|
||||
Flugi();
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue