GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Pointers and dynamic memory: leaks and argv

Christian Farris 3 Fragen

Quiz starten

Dieses Quiz enthält Fragetypen, die sich im gewohnten Player öffnen.

Fragen in diesem Quiz (3)

  1. 1Which of the following code fragments causes a memory leak?
    1. Aint *p = malloc(sizeof(int));
      int *q = malloc(sizeof(int));
      free(p);
      q = p;
      p = NULL;
    2. Bint *p = malloc(sizeof(int));
      int *q = NULL;
      q = p;
      p = malloc(sizeof(int));
    3. Cint *p = malloc(sizeof(int));
      int *q = p;
      free(p);
      q = malloc(sizeof(int));
    4. Dint *p = NULL;
      int *q = malloc(sizeof(int));
      p = q;
      free(q);
      p = malloc(sizeof(int));
    5. Eint *p = malloc(sizeof(int));
      int *q = NULL;
      q = p;
      p = NULL;
  2. 2The following command is entered (where $ is the command prompt):

    $a.out xyz1 bcde23 qrstuv456

    Which replacements for X, Y and Z in the following statement will display only the letter v in the command above?

    printf("%c\n", X(argv[Y] + Z));

    X is [blank_start]*[blank_end]

    Y is [blank_start]3[blank_end]

    Z is [blank_start]5[blank_end]
    1. A*
    2. B3
    3. C5
  3. 3#include <stdio.h>

    int main(void) {
    int i = 11;
    int *ptr1 = &i;
    int **ptr2 = &ptr1;
    int ***ptr3 = &ptr2;

    printf("%p, %p, %p, %p\n", ptr1, ptr2, ptr3, &ptr3);

    return 0;
    }
    If the program output is (where _ is part of the address that is not shown):
    0x_0b4, 0x_0b8, 0x_0c0, 0x_0c8

    At address 0x_0b4 is stored [blank_start]11[blank_end] .
    At address 0x_0c8 is stored [blank_start]0x_0c0[blank_end] .
    1. A11
    2. B0x_0c0

Informationen

Beschreibung
Quiz am Ohne Titel, erstellt von Christian Farris am 28/04/2018.
Sprache
English
Aufrufe
0
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck