Загрузка...

C Multidimensional Array MCQ | What Happens with printf("%s", a)? | Pointer Decay Trick

In this video, we analyze a tricky C programming MCQ involving a 3-dimensional character array and the use of printf("%s", **a).

The array is declared as:
char a[2][3][3] = { 'c','o','u', 'n','t','w', 'o','r','d' };

Key concepts involved:
Character arrays in multiple dimensions
Pointer decay when using %s
How **a is interpreted
Why using %s is dangerous when the memory is not null-terminated

Since **a points to 'c', but it is not a C-string (no terminating \0), using %s will read beyond valid memory.
This results in undefined behavior, most likely Segmentation Fault.

Correct Answer: d) Segmentation Fault

Keywords

multidimensional array MCQ C, printf %s undefined behavior, C pointer decay MCQ, segmentation fault due to %s, C tricky output questions, character array without null terminator, C interview MCQ, multidimensional char array explanation, pointer dereference MCQ C.

Hashtags

#cprogramming #clanguage #cmcq #arrays #multidimensionalarray #pointer #cinterviewquestions #codingmcq #dailycoding #1printf

Видео C Multidimensional Array MCQ | What Happens with printf("%s", a)? | Pointer Decay Trick канала 1printf
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять