DEV Community

Dhanashree Rugi
Dhanashree Rugi

Posted on • Edited on

3 3

Puzzle-2

Can you guess the output without the help of code editor ?

If yes, then comment the output in the below comment section.

#include <stdio.h>
#include <stdlib.h>
struct res
{
    char *name;
    int age;
}*ptr;

int main()
{
    char name[100] = "Dhanashree";
    ptr = (struct res *)malloc(sizeof(struct res));
    ptr->name = name;
    ptr->age = 28;
    printf("name = %s\n", ptr->name);
    printf("age = %d", ptr->age);
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay