Ϊʲôһֱµ÷ÊÔ²»³É¹¦°¡£¬Çó°ïÖú£¡£¡£¡
#include <stdio.h>void main()
{
struct date
{
int year;
int month;
int day;
};
struct boy
{
int num;
char name;
char sex;
char address;
float score;
struct date birthday;
}boy1,boy2;
boy1.num = 43;
boy1.name[] = "tom";
boy2 = boy1;
printf("Name = %s,Num = %d\n",boy2.name,boy2.num);
} #include <stdio.h>
#include <string.h>
void main()
{
struct date
{
int year;
int month;
int day;
};
struct boy
{
int num;
char name;
char sex;
char address;
float score;
struct date birthday;
} boy1, boy2;
boy1.num = 43;
strcpy(boy1.name, "tom");
boy2 = boy1;
printf("Name = %s, Num = %d\n", boy2.name, boy2.num);
} ³£Á¿×Ö·û´®²»ÄÜÖ±½Ó¸³Öµ¸ø×Ö·ûÊý×é ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±»¸³Öµ£¬¾Í²»ÄÜʹÓã¬Ç¿Ðи³Öµ»á±ä³ÉÂÒÂ룻
boy2=boy1Õâ¸öÓï¾äÊǽ«boy1µÄÈ«²¿³ÉÔ±¸³Öµ¸øboy2µÄÈ«²¿³ÉÔ±£¬µ«Äãboy1µÄ³ÉÔ±²¢Ã»ÓÐÍêÈ«½øÐгõʼ»¯£¬ËùÒԻᱨ´í¡£ boy1.name[]ÊÇÒ»¸öµØÖ·³£Á¿£¬²»ÔÊÐí¸Ä±ä£¬µ«ÊÇÊý×éÖеÄÔªËØÊDZäÁ¿£¬¿ÉÒԸı丳ֵ£¨Êý×éÃûÕâ¸öµØÖ·[³£Á¿]¾ÍÊÇÔªËØ[±äÁ¿]µÄ´æ·ÅλÖã©¡£
²»ÄÜÓø³ÖµÓï¾ä½«Ò»¸ö×Ö·û´®³£Á¿Ö±½Ó¸³¸øÒ»¸ö×Ö·ûÊý×é¡£
¸³Öµ¿ÉÒÔʹÓÃstrcpyº¯Êý£¬strncpyº¯Êý£¬»òÕßsprintfº¯Êý¶¼ÐУ¬Ö±½ÓµÈÓÚÊDz»Ðеġ£
¹æ¶¨²»ÄÜÕûÌåÒýÓã¬Ö»Äܵ¥¸öÒýÓ᣸³Öµ³ýÁË°´×Ö·û´®ÊäÈ븳¸ø×Ö·ûÊý×飬»òÕß³õʼ»¯Îª×Ö·û´®Í⣬һ°ãÖ»Äܵ¥¸öÔªËظ³Öµ
ͺ×Ó½¢³¤ ·¢±íÓÚ 2019-11-4 17:00
ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±» ...
ºÃÏñ²»ÊÇÕâ¸öÎÊÌâ ¶óÑÔabc ·¢±íÓÚ 2019-11-4 21:35
ºÃÏñ²»ÊÇÕâ¸öÎÊÌâ
boy1.name[] = "tom";
ÄãÔõô֪µÀ²»ÊÇÕâ¸öÎÊÌ⣿CÓïÑÔÖÐÓÐÕâÑùµÄÓï·¨Â𣿻¹Õâô¿Ï¶¨µÄ˵²»ÊÇÕâ¸öÎÊÌ⣬ÄãÄÄÀ´µÄ×ÔÐÅ£¿
ÈËÔìÈË ·¢±íÓÚ 2019-11-4 23:32
ÄãÔõô֪µÀ²»ÊÇÕâ¸öÎÊÌ⣿CÓïÑÔÖÐÓÐÕâÑùµÄÓï·¨Â𣿻¹Õâô¿Ï¶¨µÄ˵²»ÊÇÕâ¸öÎÊÌ⣬ÄãÄÄÀ´µÄ×ÔÐÅ£¿
ÎÒ˵µÄÊÇÕâ¸öÎÊÌ⣺
ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±»¸³Öµ£¬¾Í²»ÄÜʹÓã¬Ç¿Ðи³Öµ»á±ä³ÉÂÒÂ룻
boy2=boy1Õâ¸öÓï¾äÊǽ«boy1µÄÈ«²¿³ÉÔ±¸³Öµ¸øboy2µÄÈ«²¿³ÉÔ±£¬µ«Äãboy1µÄ³ÉÔ±²¢Ã»ÓÐÍêÈ«½øÐгõʼ»¯£¬ËùÒԻᱨ´í¡£
ÎÒÔËÐÐÊÔ¹ý£¬±ðÕâôßÍßͱÆÈË
Ò³:
[1]