zhao
若有以下程序
#include
#include
#include
typedef struct stu {
char *name, gender;
int score;
} STU;
void f(char *p)
{
p=(char *)malloc(10);
strcpy(p, "Qian");
}
main()
{
STU a={NULL, 'm', 290}, b;
a.name=(char *)malloc(10);
strcpy( a.name, "Zhao" );
b = a;
f(b.name);
b.gender = 'f'; b.score = 350;
printf("%s,%c,%d,", a.name, a.gender, a.score);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
则程序的输出结果是
若有以下程序
#include
typedef struct stu {
char name[10], gender;
int score;
} STU;
void f(STU a, STUB)
{ b = a;
printf( "%s,%c,%d,", b.name, b.gender, b.score );
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(a,b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
则程序的输出结果是
若有以下程序
#include
#include
typedef struct stu { char name[10], gender;
int score;
} STU;
void f( char *p )
{ strcpy( p, "Qian" ); }
main()
{ STU a={"Zhao", 'm', 290}, b;
b=a;
f(b.name);
b.gender = 'f'; b.score = 350;
printf("%s,%c,%d,", a.name, a.gender, a.score);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
则程序的输出结果是
有以下程序
#include
struct STU{ char name[9]; char sex; int score[2]; } ;
void f( struct STU a[] )
{ struct STU b = {"Zhao", 'm', 85, 90};
a[1] = b;
}
main()
{ struct STU c[2]={ {"Qian", 'f', 95, 92}, {"Sun", 'm', 98, 99} };
f(c);
printf( "%s,%c,%d,%d,", c[0].name, c[0].sex, c[0].score[0], c[0].score[1] );
printf( "%s,%c,%d,%d\n", c[1].name, c[1].sex, c[1].score[0], c[1].score[1] );
}
程序运行后输出结果是
有以下程序
#include
typedef struct stu {
char name[10];
char gender;
int score;
} STU;
void f(STU *a, STU *b)
{ b = a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(&a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
程序的运行结果是
有以下程序
#include
#include
typedef struct stu {
char name[10];
char gender;
int score;
} STU;
void f(STU c)
{ strcpy(c.name, "Qian");
c.gender = 'f';
c.score = 350;
}
main()
{ STU a={"Zhao", 'm', 290}, b;
b=a;
f(b);
printf("%s,%c,%d,", a.name, a.gender, a.score);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
程序的运行结果是
有以下程序
#include
typedef struct stu {
char name[10];
char gender;
int score;
} STU;
void f(STU *a, STU *b)
{ *b = *a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(&a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
程序的运行结果是