N
Neo
Thanks to all those who responded. Your tips really worked. So I will
give a simple program to explain, how I did it.
#include<stdio.h>
void update();
struct fields
{
char f1[20];
char f2[20];
char f3[20];
};
typedef struct
{
struct fields row[5];
} query_result;
main()
{
query_result e;
update(&e);
printf("\nYou entered %s\n",e.row[1].f1);
printf("\nYou entered %s\n",e.row[2].f2);
printf("\nYou entered %s\n",e.row[3].f3);
}
void update(query_result *p)
{
char n[20];
printf("\nInput first number: ");
scanf("%s",&n);
strcpy(p->row[1].f1,n);
printf("\nInput second number: ");
scanf("%s",&n);
strcpy(p->row[2].f2,n);
}
I defined a structure in the main program and then passed its
reference to the function (not sub-routine ;-)). Then from within the
function I populated the output in structure and it was passed on to
main function successfully.
Thanks once again.
Take care,
Rizwan.
give a simple program to explain, how I did it.
#include<stdio.h>
void update();
struct fields
{
char f1[20];
char f2[20];
char f3[20];
};
typedef struct
{
struct fields row[5];
} query_result;
main()
{
query_result e;
update(&e);
printf("\nYou entered %s\n",e.row[1].f1);
printf("\nYou entered %s\n",e.row[2].f2);
printf("\nYou entered %s\n",e.row[3].f3);
}
void update(query_result *p)
{
char n[20];
printf("\nInput first number: ");
scanf("%s",&n);
strcpy(p->row[1].f1,n);
printf("\nInput second number: ");
scanf("%s",&n);
strcpy(p->row[2].f2,n);
}
I defined a structure in the main program and then passed its
reference to the function (not sub-routine ;-)). Then from within the
function I populated the output in structure and it was passed on to
main function successfully.
Thanks once again.
Take care,
Rizwan.