54ºÚ¿Æ¼¼ ·¢±íÓÚ 2019-11-4 11:33:20

Ϊʲôһֱµ÷ÊÔ²»³É¹¦°¡£¬Çó°ïÖú£¡£¡£¡

#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);
}

Charlesδ•„ ·¢±íÓÚ 2019-11-4 12:59:28

#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);
}

Charlesδ•„ ·¢±íÓÚ 2019-11-4 13:00:14

³£Á¿×Ö·û´®²»ÄÜÖ±½Ó¸³Öµ¸ø×Ö·ûÊý×é

ͺ×Ó½¢³¤ ·¢±íÓÚ 2019-11-4 17:00:35

ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±»¸³Öµ£¬¾Í²»ÄÜʹÓã¬Ç¿Ðи³Öµ»á±ä³ÉÂÒÂ룻
boy2=boy1Õâ¸öÓï¾äÊǽ«boy1µÄÈ«²¿³ÉÔ±¸³Öµ¸øboy2µÄÈ«²¿³ÉÔ±£¬µ«Äãboy1µÄ³ÉÔ±²¢Ã»ÓÐÍêÈ«½øÐгõʼ»¯£¬ËùÒԻᱨ´í¡£

¶óÑÔabc ·¢±íÓÚ 2019-11-4 21:34:40

boy1.name[]ÊÇÒ»¸öµØÖ·³£Á¿£¬²»ÔÊÐí¸Ä±ä£¬µ«ÊÇÊý×éÖеÄÔªËØÊDZäÁ¿£¬¿ÉÒԸı丳ֵ£¨Êý×éÃûÕâ¸öµØÖ·[³£Á¿]¾ÍÊÇÔªËØ[±äÁ¿]µÄ´æ·ÅλÖã©¡£
²»ÄÜÓø³ÖµÓï¾ä½«Ò»¸ö×Ö·û´®³£Á¿Ö±½Ó¸³¸øÒ»¸ö×Ö·ûÊý×é¡£
¸³Öµ¿ÉÒÔʹÓÃstrcpyº¯Êý£¬strncpyº¯Êý£¬»òÕßsprintfº¯Êý¶¼ÐУ¬Ö±½ÓµÈÓÚÊDz»Ðеġ£
¹æ¶¨²»ÄÜÕûÌåÒýÓã¬Ö»Äܵ¥¸öÒýÓ᣸³Öµ³ýÁË°´×Ö·û´®ÊäÈ븳¸ø×Ö·ûÊý×飬»òÕß³õʼ»¯Îª×Ö·û´®Í⣬һ°ãÖ»Äܵ¥¸öÔªËظ³Öµ

¶óÑÔabc ·¢±íÓÚ 2019-11-4 21:35:37

ͺ×Ó½¢³¤ ·¢±íÓÚ 2019-11-4 17:00
ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±» ...

ºÃÏñ²»ÊÇÕâ¸öÎÊÌâ

ÈËÔìÈË ·¢±íÓÚ 2019-11-4 23:32:50

¶óÑÔabc ·¢±íÓÚ 2019-11-4 21:35
ºÃÏñ²»ÊÇÕâ¸öÎÊÌâ

boy1.name[] = "tom";
ÄãÔõô֪µÀ²»ÊÇÕâ¸öÎÊÌ⣿CÓïÑÔÖÐÓÐÕâÑùµÄÓï·¨Â𣿻¹Õâô¿Ï¶¨µÄ˵²»ÊÇÕâ¸öÎÊÌ⣬ÄãÄÄÀ´µÄ×ÔÐÅ£¿

¶óÑÔabc ·¢±íÓÚ 2019-11-5 09:33:14

ÈËÔìÈË ·¢±íÓÚ 2019-11-4 23:32
ÄãÔõô֪µÀ²»ÊÇÕâ¸öÎÊÌ⣿CÓïÑÔÖÐÓÐÕâÑùµÄÓï·¨Â𣿻¹Õâô¿Ï¶¨µÄ˵²»ÊÇÕâ¸öÎÊÌ⣬ÄãÄÄÀ´µÄ×ÔÐÅ£¿

ÎÒ˵µÄÊÇÕâ¸öÎÊÌ⣺
ÄãµÄboy1µÄnumºÍname½øÐÐÁ˸³Öµ£¬ÄÇboy1.numºÍboy1.name¿ÉÒÔ¶Ôboy2µÄnumºÍname½øÐи³Öµ£¬¶øÆäËûµÄ±äÁ¿Ã»±»¸³Öµ£¬¾Í²»ÄÜʹÓã¬Ç¿Ðи³Öµ»á±ä³ÉÂÒÂ룻
boy2=boy1Õâ¸öÓï¾äÊǽ«boy1µÄÈ«²¿³ÉÔ±¸³Öµ¸øboy2µÄÈ«²¿³ÉÔ±£¬µ«Äãboy1µÄ³ÉÔ±²¢Ã»ÓÐÍêÈ«½øÐгõʼ»¯£¬ËùÒԻᱨ´í¡£
ÎÒÔËÐÐÊÔ¹ý£¬±ðÕâôßÍßͱÆÈË
Ò³: [1]
²é¿´ÍêÕû°æ±¾: Ϊʲôһֱµ÷ÊÔ²»³É¹¦°¡£¬Çó°ïÖú£¡£¡£¡