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.

Empfohlene Antworten

Veröffentlicht

Hallo!

Mal wieder ein Problem. Das vorherige ist gelöst. Destruktor funktioniert hervorragend.

Nun aber habe ich das Problem, das ich mit ofstream etwas in eine Datei schreiben will. Einmal Character (Wörter) und einmal Zahlen. Dazu benutze ich zwei Funktionen:

void caCharacterList::out() // Ausgabe der Worte mit den zugehörigen Zahlen
{
caElementChar *pEndChar;
pEndChar = m_pStartChar;
ofstream Index("c:\\Index.idx", ios::out);

Index << pEndChar->pszWord << "\t";
pEndChar->Filenumber.out();
while(pEndChar->next != NULL)
{
pEndChar = pEndChar->next;
Index << pEndChar->pszWord << "\t";
pEndChar->Filenumber.out();
}
}[/PHP]

[PHP]void caIntegerList::out()
{
m_pEndInt = m_pStartInt;

????

while(m_pEndInt->next!=NULL)
{
m_pEndInt = m_pEndInt->next;
?????
}
????
}

In der ersten Funktion, welche ich mit Word->out(); aufrufe klappt alles super. Nun möchte ich aber immer hinter das Wort eben Zahlen schreiben. was also mus ich da jetzt an die Stelle der Fragezeichen schreiben (die Fragezeichen unter der While-Schleifen stehen für das einfügen eines '\n' in die Datei)???

Bine

PS: In der Zeile

ofstream Index("c:\\Index.idx", ios::out);

steht bei mir 'ofstream Index("c:\\Index.idx", ios::out);'!!! Hier nur nicht durch die Darstellung mit PHP!

Ich hab's rausgefunden!

Muß so

void caCharacterList::out() // Ausgabe der Worte mit den zugehörigen Zahlen
{
caElementChar *pEndChar;
pEndChar = m_pStartChar;
ofstream Index("c:\\Index.idx", ios::out);

Index << pEndChar->pszWord << "\t";
pEndChar->Filenumber.out(Index);
while(pEndChar->next != NULL)
{
pEndChar = pEndChar->next;
Index << pEndChar->pszWord << "\t";
pEndChar->Filenumber.out(Index);
}
}[/PHP]

und so

[PHP]void caIntegerList::out(ofstream Index)
{
m_pEndInt = m_pStartInt;

Index << m_pEndInt->Number << "\t";
while(m_pEndInt->next!=NULL)
{
m_pEndInt = m_pEndInt->next;
Index << m_pEndInt->Number << "\t";
}
Index << "\n";
}

aussehen! Natürlich weiterhin mit 'ofstream Index("c:\\Index.idx", ios::out);'!!!

Danke trotzdem für alle die mir helfen wollten!

Bine

Vorschlag:

Du solltest nicht Deinen End-Marker benutzen, um durch die Liste zu gehen. Dann kannst Du Dir auch die Ausgabe vor der Schleife sparen:

void caIntegerList::out(ofstream Index)
{
caElementChar *pTemp = m_pStartInt;

while(NULL != pTemp)
{
Index << pTemp->Number << "\t";
pTemp = pTemp->next;
}
Index << "\n";
}[/PHP]

@Klotzkopp:

void caIntegerList::out(ofstream Index)

Übel, übel; einen Stream als Kopie zu übergeben!

Besser void caIntegerList::out(ofstream& Index)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.