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.

ifstream - oftream

Empfohlene Antworten

Hallo,

hab da mal wieder ein Problem. Und zwar möchte ich anfangen jetzt mit ifstream und ofstream in eine Datei zu schreiben und daraus zu lesen. Aber ich verstehe die Hilfe dazu nicht, und mein Buch hilft mir auch nicht wirklich.

Nehmen wir einmal an ich habe eine Datei Test.idx welche auf c: liegt. Nehmen wir weiter an ich habe ein char Array Test welches den Inhalt Test (natürlich mit Nullzeichen am Ende) enthält.

Habe dann eine Funktion:

#include <Sabine1.h> 


void main()
{
char Test={NULL};
char *filename="c:\\\Test.idx";

ifstream Datei(filename, ios::in);

cin >> Test;
cout << endl;

Datei >> Test;
cout << "\n";
PHP]
Meine Header Datei sieht folgendermaßen aus:
[PHP]#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <io.h>
#include <math.h>
#include <stdlib.h>
#include <fstream.h>[/PHP]

Die Zeile

[PHP]char *filename="c:\\\Test.idx";

wird hier falsch dargestellt, die sieht bei mir so: 'char *filename="c:\\Test.idx";' aus.

Aber es klappt so nicht.

Was mache ich falsch?

Bine

Hat sich erledigt. Ich habe meinen Fehler gefunden. Es war ein Denkfehler. Ich will ja nichts aus einer Datei rauslesen, sondern in eine Datei schreibenl, und muss deshalb ofstream benutzen.

Hab das geändert und nu klappt es....

Bine

Auch wenn das Problem schon gelöst ist:

wenn man ifstream benutzt, dann braucht man nicht mehr den Modus, wie man die Datei öffnen will angeben.

Es reicht also ifstream file (filename);

Anders liegt der Fall, wenn man fstream benutzt, dort muß man ein paar Informationen mit angeben.

Jan

#include <Sabine1.h> 

hi,

was bedeutet in deinem Code die klammer mit dem php drinne ?

Das gehört nicht zum COde, sorry, ist ein Tippfehler. Vor dem ersten PHP fehlt die erste eckige Klammer. Das benutze ich hier zum darstellen des Quellcodes. Mehr nicht.

So macht man damit aus:

class Test

{

public:

Test *b;

int a;

};

class Test
{
public:
Test *b;
int a;
};[/PHP]

Bine

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.