In a dynamic 2D array created as: int arr = (int)malloc(rows * sizeof(int*)); What is the next step?
What will happen?
char arr[5] = "Hello";
printf("%d", strlen(arr));
What happens with this code?
char *ptr;
char str[] = "Programming";
ptr = str;
ptr[2] = 'X';
What will the following code print?
int arr[3] = {10, 20, 30};
int *p = arr;
printf("%d %d", *p++, *++p);
How should dynamic 1D array of strings be declared for 5 strings of length 20?
Advertisement
What is the most efficient way to copy one array to another in C?
What is the relationship between pointer arithmetic and array indexing in C?
What potential issue exists with this code: char *ptr = "Hello"; ptr[0] = 'h';?
For a 3D array int arr[2][3][4], what is arr[1][2][3] equivalent to?
In string handling, what is the difference between fgets() and gets()?
Which of the following correctly declares a pointer to an array (not array of pointers)?
In what scenario would you use memcpy() instead of strcpy()?
What does the strspn() function do?
What is the difference between *p++ and (*p)++?
What does the following code do?
int *p = (int*)malloc(sizeof(int));
*p = 5;
free(p);
p = NULL;
Which statement is true about void pointers?
What is the output?
int x = 50;
int *p = &x;
int *q = p;
q = NULL;
printf("%d", *p);
In a function that returns a pointer, which of the following is UNSAFE?
Consider: int *p = (int *)malloc(5 * sizeof(int)); for(int i=0; i<5; i++) *(p+i) = i*10; Which statement correctly deallocates this memory?
A programmer uses a pointer variable but forgets to initialize it before dereferencing. Which type of error will occur?