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.

If-Anweisung und .eof()

Empfohlene Antworten

hey. wie kann ich in einer if-anweisung abfragen ob das file was ich auswerte eof erreicht hat?

quelltext:

char E_Mail;

char Test[255];

int i = 0;


ifstream E_Mail_Anzeige("E_Mailaddressen.txt", ios::in);

while(!E_Mail_Anzeige.eof())

{

   E_Mail_Anzeige.get(E_Mail);

   if(E_Mail_Anzeige == E_Mail_Anzeige.eof())

   {

      break;

      /*i--;

      Test[i] = '\0';*/

   }

   Test[i] = E_Mail;

   memToAddress->Text = Test;

   i++;

}

ohne die if-anweisung funktioniert es aber er zeigt das letzte zeichen doppelt an. wie kann ich das unterbinden?

Hi,

das Problem ist wenn du dir mit E_Mail_Anzeige.get(E_Mail); das letzte Zeichen holst ist

er noch nicht am Dateiende, er läuft die Schleife also nochmal durch, merkt bei der get()

Funktion das er am Ende ist (holt also nichts mehr), schreibt aber weiter unten nochmal

das zuletzt geholte Zeichen an das Ende von Test.

Am besten prüfst du bevor du an Test anfügst nochmal ob das Dateiende erreicht wurde.

Die Abfrage in deiner if Anweisung verstehe ich aber nicht, was bedeutet E_Mail_Anzeige ==

E_Mail_Anzeige.eof())?

Gruß

Guybrush

das sollte sone art abfrage sein ob die txt-datei zu ende ist.

@guybrush

hab deinen tip bedacht und es auf folgende weise gelöst:

ifstream E_Mail_Anzeige("E_Mailaddressen.txt", ios::in);

while(!E_Mail_Anzeige.eof())

{

E_Mail_Anzeige.get(E_Mail);

if(E_Mail != '\0')

{

Test = E_Mail;

}

memToAddress->Text = Test;

i++;

E_Mail = '\0';

}

und funktioniert :marine

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.