C Programming :: Dynamic Memory Allocation - Discussion
Home > C Programming > Dynamic Memory Allocation > MCQs Questions Discussion
10 / 18
What will be output of the following "c" code?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char *p = "Hello";
char *q = "world";
int l1 = strlen (p);
int l2 = strlen (q);
char *l = (char*) malloc (sizeof (l1 + l2)+1);
while (*p) *l++ = *p++;
while (*q) *l++ = *q++;
*l = '\0';
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char *p = "Hello";
char *q = "world";
int l1 = strlen (p);
int l2 = strlen (q);
char *l = (char*) malloc (sizeof (l1 + l2)+1);
while (*p) *l++ = *p++;
while (*q) *l++ = *q++;
*l = '\0';
}
ASegmentation Fault
BCompilation Error
CNo output No Error
DNone of these
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
No Discussion on this question yet!