pC.NET

Welcome to oscc.kr



 구조체 선언
2020-05-12 10:43:47
Hit : 1125

작성자 : 피시키드
- File #1 : struct1.c(838 Byte), Download : 7

사용자 정의 객체로써, '.'참조로 하부로 한칸한칸 내려가면 된다.

#include <stdio.h> 

// struct [형태명]  
// application 형을 선언한다. 
struct applications { 
    char xl[15]; 
    char ppt[15]; 
    char word[15]; 
}; 

struct office { 
    int no; 
    char com[15]; 
    double ver; 
    // struct [형태명] [변수명]; 
    // apps라는 변수를 applications형으로 선언한다. 
    struct applications apps; 
}; 
    
int main() { 
    // struct [형태명] [변수명] = {구성원1, 구성원2, 구성원3 ...}; 
    // mso라는 변수를 office 형으로 선언한다. 
    struct office mso = { 1, "Microsoft", 14.0, {"MSExcel","MSPowerPoint","MSWord"} }; 
    // 'MSPowerPoint' 출력 
    printf("%s\n", mso.apps.ppt); 
    // 'MSExcel'의 세번째 글자인 'E' 출력  
    printf("%c\n",mso.apps.xl[2]); 
    // 12.31 출력 
    mso.ver = 12.34; 
    printf("%.2f\n", mso.ver); 
    
    return 0; 
}

* 피시키드님에 의해서 게시물 이동되었습니다 (2024-04-26 18:49)

  피시키드
회원님의 소개글이 없습니다.
 6490
 83


미로찾기 [우수법]
문자열 좌우회전 이동

Copyright (C) 1997-2025 All Rights Reserved.

Powered by
DNS server, DNS service 우분투 리눅스 웹서비스 AbuseIPDB Contributor Badge