Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
Question 1
:
Will the following code work?
#include<stdio.h>
#include<malloc.h>
struct emp
{
int len;
char name[1];
};
int main()
{
char newname[] = "Rahul";
struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 +
strlen(newname)+1);
p->len = strlen(newname);
strcpy(p -> name, newname);
printf("%d %s ", p->len, p->name);
return 0;
}
1.
Yes
2.
No