Contents

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

시간 날짜, 요일 출력 초간단 예제 코드

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
    time_t  ltime;
    struct tm *today;
    int daysofmonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    char weekstr[][3] = { "일", "월", "화", "수", "목", "금", "토" };
    int year, month, day, month2, th, rmd, adayofweek, OldSec=0;

    while(1){
        time(<ime);
        today = localtime(<ime);

        year = today->tm_year + 1900;
        month = today->tm_mon + 1;
        day = today->tm_mday;

        if (month<=2) {
            rmd = year-1;
            month2 = month+12;
        }
        else {
            rmd = year;
            month2 = month;
        }
        th = rmd/100;
        rmd %= 100;
        adayofweek = (21*th/4 + 5*rmd/4 + 26*(month2+1)/10 + day-1) % 7;

        if ( OldSec != today->tm_sec )
        {
            system("cls");
            printf("%04d. %02d. %02d. (%s) %02d:%02d:%02d KST
",
                // tm_year는 1900을 더해야 서기 연도가 됨
                today->tm_year + 1900,

                // tm_mon은 1월이 0, 2월이 1... 식으로 되어 있음
                today->tm_mon + 1,
                today->tm_mday,
                weekstr[adayofweek],
                today->tm_hour,
                today->tm_min,
                today->tm_sec);
                OldSec = today->tm_sec;
        }
    }
    return 0;
}


?

  1. 해커스랩 깨기.. 후후.. ㅋㅋ

    Date2013.04.23 CategorySystem/OS Byhooni Views18425
    Read More
  2. 플라스터(Plaster) 수업 내용

    Date2016.05.24 CategoryEtc Byhooni Views0
    Read More
  3. 프로그램 문서 관리 (Doxygen)

    Date2013.04.23 CategoryDevelop Byhooni Views16394
    Read More
  4. 프로그래밍에서 foo, bar 함수의 유래

    Date2013.06.25 CategoryDevelop Byhooni Views21276
    Read More
  5. 프로그래밍 소스 관련 사이트..

    Date2013.04.23 CategoryDevelop Byhooni Views16489
    Read More
  6. 페이팔에서 돈 찾기 (Paypal withdraw)

    Date2014.02.20 CategoryDevelop Byhooni Views11397
    Read More
  7. 티스토리 테이블 html,css 구문

    Date2013.11.03 CategoryEtc Byhooni Views15969
    Read More
  8. 콘솔에서 패스워드 걸린 zip 압축하는 명령

    Date2018.03.02 CategorySystem/OS Byhooni Views960
    Read More
  9. 컴파일러 수업 자료(교재 : 컴파일러 입문)

    Date2003.04.23 CategorySystem/OS Byhooni Views21975
    Read More
  10. 캘리포니아 운전면허 족보

    Date2017.06.12 CategoryDevelop Byhooni Views754
    Read More
  11. 캘리포니아 운전면허 문제

    Date2017.07.22 CategoryEtc Byhooni Views992
    Read More
  12. 최근 논문 자료 (2011/01/03, 만현형한테 보낸거..)

    Date2013.04.23 CategoryDevelop Byhooni Views10366
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 98 Next
/ 98