#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct org
{
char name[40];
int profit;
int persono;
};
int main()
{
struct org *o;
int i,n;
printf("How much org :- ");
scanf("%d",&n);
o=(struct org*)calloc(n, sizeof(struct org));
for (i=0; i<n; ++i)
{
printf("Give the Name of Organization - ");
fgets((o+i)->name,sizeof((o+i)->name),stdin);
(o+i)->name[strcspn((o+i)->name,"\n")]='\0';
printf("Name of company is :- %s",(o+i)->name);
}
free(o);
return 0;
}
The first loop isn't working please help out. I used fgets for this and but its working with scanf. And my question is Short stack overflow is making me write these lines too. Very Disgusting.