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,

wie kann ich bei folgendem Beispiel die Größe in Bytes des Arrays 't' ermitteln?


#define ANZAHL 1000000
#define STELLEN 700

char **t;

main()
{
t = (char**)calloc(ANZAHL,sizeof(char*));
for (int i=0; i<ANZAHL; i++)
{
t[i] =(char*)calloc(STELLEN,sizeof(char));
for (int u=0; u<STELLEN-1; u++)
t[i][u] = 'a';
t[i][u+1] = '\0';
}
printf("%i\t%s\n",sizeof(t),t[ANZAHL-1]);
free(t);
return 0;
}
[/PHP]

Es müßten ja am Ende 700MB für t reserviert sein, aber mit sizeof(t) bekomme ich immer

4 ausgegeben da ein Pointer ja 4 Byte groß ist.

Gruß

Guybrush

Der Stern hat (wenn man mal vom Multiplikationsoperator absieht) zwei Bedeutungen: Er dient zur Deklaration eines Zeigers, oder oder als sogenannter Dereferenzierungsoperator.

Der Derefenzierungsoperator kann nur auf Zeiger angewendet werden, und macht daraus das Objekt, auf das der Zeiger zeigt. Er ist praktisch die Umkehrung des Adressoperators &.

Beispiel:

int x = 1;

int y = 2;

int* p = &x; // p zeigt auf x

*p = 4; // jetzt ist x = 4

p = &y; // jetzt zeigt p auf y

(*p)++; // jetzt ist y = 3

Die Klammern in der letzten Zeile sind notwenig, weil der Postinkrementoperator eine höhre Priorität als der Derefenzierungsoperator hat. Würde man die Klammern weglassen, würde zuerst der Zeiger inkrementiert, und danach derefenziert, mit unabsehbaren Folgen.

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.