好的,所以我的目标是使用该函数来填充字符串数组,然后它将返回这些字符串数组:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int getinfo (char* nam[], int ag[], char* dot[], char* gende[], int x)
{
printf ("What is the student's name?\t");
scanf ("%d", &nam[x]);
printf ("\nWhat is the student's age?\t");
scanf ("%d", &ag[x]);
printf ("\nWhat is the student's Date of Birth?\t");
scanf ("%s", &dot[x]);
printf ("\nWhat is the student's gender?\t");
scanf ("%c", &gende[x]);
printf ("\nWhat is the student's adress?\t");
return nam[x];
}
int main ()
{
int amount, y;
printf("How many students are you admitting?\t");
scanf ("%d", &amount);
char *name[50], *dob[50], gender[50];
int age[50];
for(y = 0; y < amount; y++)
{
getinfo(&name[y], &age[y], &dob[y], &gender[y],y);
}
system("pause");
}