Views 7666 Votes 0 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
구조체 배열에 학생 성적 입력 받아서..
총점,평균 계산해서 파일 출력하는 간단한.. ㅋㄷ
상언아~ 좋지? ㅋㄷ

입력 받고 출력하는 주요 함수

/* 점수 받아옴 (도중에 exit 나 그냥 엔터 치면 종료) */
void get_marks(){
    int i;
    char tmp[LEN]={0,};

    for(i=0; i<ARR; i++){
        printf("\n## %d 번째 학생 ##\n", i+1);
        printf("학    번 : ");
        fgets(tmp, LEN, stdin);
        if(isexit(tmp)) return;
        strcpy(std[i].hak, tmp);

        printf("이    름 : ");
        fgets(tmp, LEN, stdin);
        if(isexit(tmp)) return;
        strcpy(std[i].name, tmp);

        printf("리 눅 스 : ");
        fgets(tmp, LEN, stdin);
        if(isexit(tmp)) return;
        std[i].lin=atol(tmp);

        printf("프로그램 : ");
        fgets(tmp, LEN, stdin);
        if(isexit(tmp)) return;
        std[i].pro=atol(tmp);

        std[i].total=std[i].lin + std[i].pro;
        std[i].avg=(std[i].lin + std[i].pro) / 2;

        /* 출력할 때 몇 개 출력할건지 루프 돌아야 하는 카운트 */
        num++;
    }
}

/* 파일로 출력하는 함수 */
void print_marks(){
    FILE *fp;
    int i;

    /* 파일 열기 */
    if((fp=fopen("data.dat","w"))==NULL){
        printf("\nfile open error!\n\n");
        return;
    }

    fprintf(fp, "## 결과 ## \n");
    fprintf(fp, "%s\t %8s\t% 4s\t %4s\t %4s\t %4s\n","학번","성명","리눅스", "프로그램", "총점", "평균");
    for(i=0; i<num; i++){
        fprintf(fp, "%s\t %8s\t %5.0f\t %8.0f\t %4.0f\t %4.2f\n",
            std[i].hak, std[i].name, std[i].lin, std[i].pro, std[i].total, std[i].avg
            );
    }
    fclose(fp);

    printf("\n결과가 data.dat 파일로 출력되었습니다\n\n");
}

?

List of Articles
No. Category Subject Author Date Views
25 Develop [Android Error] The number of method references in a .dex file cannot exceed 64K hooni 2016.11.10 752
24 Develop [ajax] 이벤트 코드 생성기 작업중.. ㅋㅋ file hooni 2013.04.23 7116
23 Develop [ajax] 샘플 코드와 한글처리에 대한 간단한 설명 hooni 2013.04.23 6842
22 Develop ZBar 라이브러리를 이용한 바코드 스캔 앱 개발하기 file hooni 2015.01.01 1628
21 Develop XML, JSON, BSON, MSGPACK 장,단점 비교 file hooni 2017.01.11 2237
20 Develop XE Core 1.8.18 본문 작성시 태그(html) 사라지는 버그 file hooni 2016.04.21 862
19 Develop What is difference between Get, Post, Put and Delete? hooni 2018.02.28 1398
18 Develop URI 인코딩, URL 인코딩 file hooni 2013.04.23 18845
17 Develop SVN 초간단 사용하기 hooni 2014.02.28 7616
16 Develop SVN 명령어 (SVN command) hooni 2014.02.28 12137
15 Develop OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..) file hooni 2013.04.23 13917
14 Develop OpenGL 강좌 사이트 모음 hooni 2013.04.23 9637
13 Develop OGNL(Object Graph Navigation Language) hooni 2013.04.23 15727
12 Develop macOS에 node, npm 설치하기 (homebrew) file hooni 2021.11.06 1137
11 Develop Mac OS 에 Jenkins 설치하기 (Homebrew) 2 file hooni 2017.03.15 8088
10 Develop Laravel 5 Failed opening required bootstrap/../vendor/autoload.php hooni 2018.01.24 1650
Board Pagination Prev 1 ... 49 50 51 52 53 Next
/ 53