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.

Strings

Empfohlene Antworten

Wie kann ich machen dass ich nur strings ins textaray reinschreib wo was drinnsteht. weil sonst gibts dann *******se aus

ofstream dateiAus;

string xspieler[x];

dateiAus.open(dateiname.c_str(), ios_base::out);

for(x=0;x<=19;x++)

{

if(xspieler[x]!=NULL)

{

dateiAus << xspieler[x] << endl;

dateiAus << highscore[x] << endl;

}

}

Probiers mal mit

if(strlen(xspieler[x])!=NULL)

und wenn´s dann immer noch nicht klappt, Initialisiere vorher noch die Strings

string xspieler[x];
for (int y=0; y<x; y++)
xspieler[y]="";
[/PHP]

Probiers mal mit

if(strlen(xspieler[x])!=NULL)

strlen funktioniert nur mit C-Strings (char-Arrays und -Zeiger).

und wenn´s dann immer noch nicht klappt, Initialisiere vorher noch die Strings

string xspieler[x];
for (int y=0; y<x; y++)
xspieler[y]="";
[/PHP]

Objekte der Klasse std::string sind automatisch "leer" initialisiert.

@reuabreliz:

std::string hat eine length-Methode, die kannst du benutzen:

[code]if(xspieler[x].length() != 0)[/code]

thx :) hat mir wirklich geholfen :uli

@Klotzkopp

Ich muß zugeben, daß ich in der letzten Zeit nur mit CATUnicodeStrings, CStrings und einer eigenen String-Klasse (RXStrings) zu tun hatte, die ich mir zur Zeit zusammenpfriemel. Mit Stds hab ich seit Ewigkeiten nichts mehr am Hut, dachte aber, die wären 0-terminiert.

Das Problem mit strlen ist nicht die Nullterminierung (die der Standard übrigens nicht garantiert), sondern dass es keine implizite Konvertierung von std::string in const char* gibt. Dazu hat std::string die Methode c_str. Die liefert dann auch einen Zeiger auf einen nullterminierten String. Aber da ist std::string::length erheblich effizienter.

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.