Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Funktionswerte formatiert in Textdatei schreiben

Empfohlene Antworten

Veröffentlicht

Hallo....

ich habe ein Programm, mit dem ich Funktionswerte in eine Textdatei schreibe.

Leider komm ich bei der Formatierung gar nicht weiter:

i + 1. Datensatz: i x y a

wobei der 1. Datensatz den Definitionsbereich xvon xbis beinhalten soll


FILE *fp;

                char name[40];

                printf("Dateiname:");scanf("%s",name);

        fp = fopen(name,"w+");


        if(fp==NULL) {

                printf("Error: Dateieroeffnung");

                return 0;

        }


        for( x=0.1; x < 0.2; x += 0.003) {

                y = 100-(x/0.002);

                a = fabs((Summe/n)-y);

                printf("%20.3f %16.3f %20.3f\n", x, y, a);

                fprintf(fp, "%20.3f %16.3f %20.3f\n", x, y, a);

        }


        fclose (fp);

        return 0;

}

kann mir bitte jemand weiterhelfen?

Hallo, und Willkommen auf dem Board :)

Leider komm ich bei der Formatierung gar nicht weiter:
Das ist als Problembeschreibung etwas mager :(

kann mir bitte jemand weiterhelfen?
Wo genau hängts denn?

Weißt du nicht, wie du den Zähler ausgeben sollst? Oder die erste Zeile?

Ganz allgemein würde ich einen int als Schleifenvariable benutzen, und den Float-Wert jedesmal neu berechnen (startwert + i * schrittweite). Das Aufaddieren von Fließkommawerten zieht nämlich immer größer werdende Rundungsfehler nach sich.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.