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

Hi @ all,

ich habe folgendes Problem. Ich habe ein CharArray mit folgenden werten.

0x45,0x4B,....

Beispiel:

array[0] = 0

array[1] = x

array[2] = 4

array[3] = 5

array[4] = 0

array[5] = x

array[6] = 4

array[7] = B

...

Wie kann ich jetzt den Hex-Wert am Besten in ein einzelnes Array-Feld schreiben. Es soll aber weiterhin ein CharArray bleiben.

Beispiel:

array[0] = 0x45 = E

array[1] = 0x4B = K

...

also ich will ein Array in dem der Wert "E" steht. Welches ja den Hex-Wert 0x45 entspricht.

Hallo,

array[0]=0x45 schreibt den Wert 0x45 und damit auch den Character "E" in dein Array. Die Ausgabe auf dem Schirm ist eigentlich nur davon abhängig, welches Format bei der Bildschirmausgabe (beispielsweise "printf") gewählt wird.

Nic

Original geschrieben von nic_power

Hallo,

array[0]=0x45 schreibt den Wert 0x45 und damit auch den Character "E" in dein Array. Die Ausgabe auf dem Schirm ist eigentlich nur davon abhängig, welches Format bei der Bildschirmausgabe (beispielsweise "printf") gewählt wird.

Nic

Das beantwortet aber meine Frage nicht. Wie bekomme ich das eine Format von Arry1 in das Format von Array2 (siehe oben)?

Hi,

in dem Du die Werte vorher mit strtol() konvertierst:

char tmp[5];

tmp[0]=array[0];

tmp[1]=array[1];

tmp[2]=array[2];

tmp[3]=array[3];

tmp[4]=0;

array[0]=strol(tmp, (char **)NULL, 16);

Da Dein Ausgangsarray mehrere Werte enthält, solltest Du das über eine Schleife realisieren (setzt allerdings voraus, das die Werte einen festen Offset innerhalb des Array haben, ist das nicht der Fall, wirst Du Dir einen Miniparser zum Erkennen von Hex-Werten schreiben müssen).

Nic

Danke!

Genau das habe ich gebraucht.

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.