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.

ascii-tabelle

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich bin noch neu hier und hätte ein kleines Problem.

Ich soll als Hausaufgabe eine Tabelle Programmieren die den ascii code in einer Tabelle ausgibt.

Ich habe es mit zwei verschiedenen Varianten versucht. Leider hat keine von beiden funktioniert. es würde mich echt freuen wenn mir jemand helfen könnte

1. ) versuch: gibt zwar tabelle und ascii code aus, aber nur jedes 2 Zeichen:

#include <math.h>

#include <stdio.h>

main () {

int i, j;

double k = 31;

for (i = 1; i <= 19; i++){

for (j= 1; j<=5; j++)

printf("%3d = '%1c' ", k ++, k ++ );

putchar ('\n');

}

}

2. Versuch: gibt leider nur das erste Zeichen des ascii code aus..

#include <math.h>

#include <stdio.h>

main () {

int i, j=0, m=5, k = 31;

if (k <= 126 && k%5 == 0) {

k++;

printf("%3d = '%c' ", k, k);

putchar ('\n');}

else {

k++;

printf("%3d = '%c' ", k, k);

}

}

es würde mich freuen, wenn mir jemand helfen könnte.

Zu 1) ist auch klar, dass nur jedes zweite Zeichen kommt, Du machst auch zweimal k++. k sollte auch kein double sein :D

Zu 2) ist auch klar, da fehlt die Schleife komplett.

Eine beliebte Variante für die 128 ASCII-Zeichen, welche in 7-Bit (0..127) abgebildet werden, darzustellen ist in 8 Zeilen á 16 Zeichen.

Das kann man auf vielen Wegen machen, mit 2 ineinander verschachtelten Schleifen, oder einer Schleife mit Integer-Division / und Modulo %.

#include <stdio.h>


void main()

{

	int i = 0, cols = 16;

	while ( i < 127 )

	{

		printf("%1c", i++);

		if ( (i % cols) == 0 )

			printf("\n");

	}

}

vielen Dank :)

habs jetzt hinbekommen

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.