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.

Frage zu _stprintf_s

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich muss mal long mal BYTE in _TCHAR Array konvertieren.

Momentan mache ich es mit _stprintf_s, leider sobald der Parameter zu groß ist als angegeben schmiert das Programm logischerweise ab.

Beispiel:


Fun(BYTE value)
{
_TCHAR text[2];
_stprintf_s(text, 2, _T("%01d"), value);
}

[/PHP]

Die einzige Lösung die mir Einfalt ist, den Wert einfach auf länge zu überprüfen, das einzige Problem dabei ist, dass es viele Funktionen sind :(

Deshalb die Frage: kann man es schöner bzw. effizienter lösen?

Gruß

mache ich doch,
Nein, machst du nicht. Für %d mit BYTE brauchst du ein Array von fünf TCHARs, nicht zwei.

und zwar ohne exception
Eine Exception ist bei einer Funktion aus einer C-Bibliothek auch kaum möglich.

Welches Verhalten hättest du denn gern in so einem Fall? Wenn dir das Verhalten des Default-Handlers für ungültige Parameter nicht gefälllt, dann schreib doch deinen eigenen.

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.