#include<stdio.h>
int qt( int *x);
struct student
{
int id;
char name[10];
char b_g[10];
float cgpa;
char address[20];
};
int num,i;
int main()
{
printf("Input How Many students You Have: ");
scanf("%d",&num);
qt(&num);
}
int qt(int *x)
{
int v,n;
v=*x;
struct student ar[v];
printf("Enter Your ID, Name, Blood Group, CGPA, Adress:\n");
for(i=1;i<=v;i++)
{
scanf("%d %s %s %f %s",&ar[i].id,ar[i].name,ar[i].b_g,&ar[i].cgpa,ar[i].address);
}
printf("\nEnter Your ID:");
scanf("%d",&n);
for(i=1;i<=v;i++)
{
if(ar[i].id==n){
printf("Student ID:%d\n\nName: %s\nBlood Group: %s\nCGPA: %f \nAddress: %s\n",n,ar[i].name,ar[i].b_g,ar[i].cgpa,ar[i].address);
}
}
}
it taking many inputs in code blocks that i don't want to do,,but in same code is working fine in VS code. I need to run it in code blocks and that should show proper output base on search id.
Firstly I would say that your qt function should probably actually return an integer at some point, seeing as you've declared the return data type without a return statement. Also, as someone mentioned above, it might be helpful going forwards to adopt the widely accepted standard of starting for loops at 0. If adding the return does not fix the issue, could you post the error message you are getting??