#include <stdio.h>
#include<string.h>
#if 0
typedef struct stu
{
	int id;
	char name[20];
}STU;
int main()
{
	STU stu1 = {1234,"hello"};
	printf("id = %d,name = %s\n",stu1.id,stu1.name);
	return 0;
}
#endif
#if 0
typedef struct student STU;
struct student
{
	int id;
	char name[100];
};
int main()
{
	//STU stu1;
	//stu1.id = 12343;
	//strcpy(stu1.name , "hello");//数组不能直接复制,所以用strcpy
	//printf("id = %d,name = %s\n",stu1.id,stu1.name);
	STU stu2 = {.name = "hello", .id = 12345};
	printf("id = %d,name = %s\n",stu2.id,stu2.name);
	return 0;
}
#endif结构体的定义与初始化
最新推荐文章于 2024-04-21 00:57:49 发布
          
          
       
          
       
       
                   
                   
                   
                   
       
           
                 
                 
                 
                 
                 
                
               
                 
                 
                 
                 
                
               
                 
                 扫一扫
扫一扫
                     
              
             
                   652
					652
					
 被折叠的  条评论
		 为什么被折叠?
被折叠的  条评论
		 为什么被折叠?
		 
		  到【灌水乐园】发言
到【灌水乐园】发言                                
		 
		 
    
   
    
   
             
            


 
            