C语言结构体赋值相关

Lucseeker posted @ 2010年10月14日 03:28 in 未分类 with tags C 结构体赋值 , 2758 阅读

看UNPv1的时候,在第四章看到ipv6结构体的赋值,里面说到C语言的结构体变量无法直接赋值为该结构的常值结构,但是可以用变量赋值,并且如果是初始化的时候也是可以的,废话少说,还是上代码说的明白:

typedef struct A { 
        int a;
        char b;
} A;

int main()
{
    
        A b = {2, 'b'}; //OK
        A a = {1, 'a'}; //OK
        /* a = {1, 'b'} //非法,结构体赋值不能用常量结构赋值,不过可以这样: */
        a = b; /* 合法,b是同类型的结构体变量 */

        return 0;
}
NCERT Computer Sampl 说:
2022年9月26日 13:27

Computer Education is most important for everyone, that’s the way the department of education have introduced computer education course from the primary school level at the Central board schools, NCERT Computer Sample Paper Class 2 and various state boards also followed the central school syllabus. So every student who is studying their Class 2 course can download the NCERT Computer Education Question Bank 2023 Class 2 with learning & Study material for all topics of the course.

civaget 说:
2024年1月18日 01:09

Trust 펀초이스 for authentic massage business reviews, guiding you to relaxation with unbiased recommendations and verified user feedback.

civaget 说:
2024年1月18日 05:52

The staff at 제주레깅스룸 are leggings experts. They helped me find the perfect pair to suit my style.

boardmodelpaper.com 说:
2024年1月22日 16:45

Board Model Papers 2024 provide all states of 6th to 10th text books 2024 Candidates who are Searching for 6th to 10th and 11th to 12th text books and syllabus, sample questions, exam pattern, and Co-Curricular Subject textbooks can refer to this entire article. boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course. Here, we have gathered all subjects of Board textbooks for all Class along with the direct download links.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter