Following is the code written to implement a employ manipulation system using pointer to structures . It makes some allocation problem in dev-cpp while work well in turbo c.
Can you help me to understand the problem

// Implement pointers to structures to produce employ manipulation and produce output 
//as producing by the query select *from employ group by designation in DBMS

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

struct employ
{
       char id[20],name[20],desig[20];
       int salary;
};

int main()
{
    struct employ *jamia;
    jamia=(struct employ *)malloc(sizeof(struct employ)*10);
    int gm=0,ow=0,man=0,exe=0,gm_sal=0,ow_sal=0,exe_sal=0,man_sal=0,i;
    char *mana="Manager",*owo="Others",*exec="Executive",*gma="Genaral Manager";
    system("cls");
    printf("Enter the details of employees one by one\n\nNote : Valid designations are GM,Manager,Executive,Others\n\n");
    for(i=0;i<5;i++)
    {
                    
                    printf("Employee ID    :  ");
                    scanf("%s",jamia[i].id);
                    fflush(stdin);
                    printf("\nName           :  ");
                    gets(jamia[i].name);
                    fflush(stdin);
                    printf("\nDesignation    :  ");
                    gets(jamia[i].desig);
                    fflush(stdin);
                    printf("\nSalary         :  ");
                    scanf("%d",jamia[i].salary);
    }
    for(i=0;i<5;i++)
    {
                    if(strcmpi(jamia[i].desig,mana)==0)
                    {
                                                       man++;
                                                       man_sal+=jamia[i].salary;
                    }
                    else if(strcmpi(jamia[i].desig,owo)==0)
                    {
                         ow++;
                         ow_sal+=jamia[i].salary;
                    }
                    else if(strcmpi(jamia[i].desig,gma)==0)
                    {
                         gm++;
                         gm_sal+=jamia[i].salary;
                    }
                    else if(strcmpi(jamia[i].desig,exec)==0)
                    {
                         exe++;
                         exe_sal+=jamia[i].salary;
                    }
    }
    printf("\n\n\n");
    printf("\nManager(%d)\t\t%d",man,man_sal);
    printf("\nExecutive(%d)\t\t%d",exe,exe_sal);
    printf("\nGeneral Manager(%d)\t%d",gm,gm_sal);
    printf("\nOther workers(%d)\t%d",ow,ow_sal);
    getch();
    free(jamia);
    return 0;
}

Sure, can you tell use what the problem is?

Ignoring the myriad issues your code has that aren't likely to be your actual problem, this line is wrong:

scanf("%d",jamia[i].salary); // Wrong

Since jamia[i].salary is not already a pointer, you need to prepend it with the address-of operator:

scanf("%d", &jamia[i].salary); // Correct
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.