#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

struct a{
           char *c;
           int b;
           }t;
    

int main()
{
    scanf("%s %d",t.c,&t.b);
    printf("%s",t.c);
    getch();
    return 0 ;
           }

I guess there is some problem in receiving input (more precisely in t.c part). Further assistance will be appreciated.

t.c is nothing more than a pointer that has no memory allocated to it. scanf() does NOT allocate the memory for you, you have to do that yourself. Change the structure to something like this and it will work.

struct a
{
   char c[255];
   int b;
};

t.c is nothing more than a pointer that has no memory allocated to it. scanf() does NOT allocate the memory for you, you have to do that yourself. Change the structure to something like this and it will work.

struct a
{
   char c[255];
   int b;
};

Thank you. I got the concept.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.