모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 게시물ID : computer_135779
    작성자 : Delver
    추천 : 1
    조회수 : 657
    IP : 125.177.***.44
    댓글 : 78개
    등록시간 : 2013/12/16 14:16:31
    http://todayhumor.com/?computer_135779 모바일
    누군가님의 과제
    몇번이나 글을 쓰는데 글이 안올라가네요 

    토욜날 점심먹으면서 짰던거라 틀린부분이, 더러운 부분이 있을수도 있습니다.


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    #ifndef MYQUEUE_H
    #define MYQUEUE_H
    #pragma warning(disable:4996)
    #include <stdlib.h>
    #include <string.h>
    typedef char* T;
     
    typedef struct qNode
    {
        T data;
        struct qNode * next;
    }qNode;
     
    typedef struct myQueue
    {
     
        qNode * front;
        qNode * back;
     
        int queueNum;
    }myQueue;
     
    int empty(myQueue *q)
    {
        //1 비어있다.
        //0 요소가 있다.
        if(q->queueNum > 0)
            return 0;
        else
            return 1;
    }
     
    void enqueue(myQueue *q, T inputData)
    {
        
        qNode * newNode;
     
        //newNode = new qNode;
        newNode = (qNode*)malloc(sizeof(struct qNode));
        newNode->next = NULL;
     
        //newNode->data = inputData;
        newNode->data = (char*)malloc( strlen(inputData) +1 );
        strcpy(newNode->data, inputData);
        *(newNode->data + strlen(inputData)) = 0;
     
        if( empty(q) )
        {
            //비어있을때의 동작
            q->front = newNode;
            q->back = newNode;
        }
        else
        {
            q->back->next = newNode;
            q->back = newNode;
        }
        q->queueNum++;
     
     
        return;
    }
     
    void initQueue(myQueue *q)
    {
        q->front = NULL;
        q->back = NULL;
        q->queueNum = 0;
    }
     
     
    T frontQueue(myQueue *q)
    {
        return q->front->data;
    }
     
    T backQueue(myQueue *q)
    {
        return q->back->data;
    }
     
    void deQueue(myQueue *q)
    {
        qNode * temp;
     
        //큐에서 삭제
        if(empty(q))
        {
            return;
        }else
        {
            temp = q->front;
            q->front = q->front->next;
            
            //char * 자원해제
            free(temp->data);
            free(temp);        
            q->queueNum--;
        }
     
    }
     
    void destroyQueue(myQueue *q)
    {
        while( !empty(q) )
        {
            //dequeue를 한면서 메모리를 해제한다.
            deQueue(q);        
     
     
        }
     
    }
     
    #endif

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    #include <stdio.h>
    #include <sys/types.h>
     
    #include "MyQueue.h"
    #include "dirent.h"
     
    #pragma warning(disable:4996)
     
    myQueue mQueue;
     
    static int
    find_directory(
        const char *dirname)
    {
        DIR *dir;
        char buffer[PATH_MAX + 2];
        char *p = buffer;
        const char *src;
        char *end = &buffer[PATH_MAX];
        int ok;
        char * extName;
     
        /* Copy directory name to buffer */
        src = dirname;
        while (p < end  &&  *src != '\0') {
            *p++ = *src++;
        }
        *p = '\0';
     
        /* Open directory stream */
        dir = opendir (dirname);
        if (dir != NULL) {
            struct dirent *ent;
     
            /* Print all files and directories within the directory */
            while ((ent = readdir (dir)) != NULL) {
                char *q = p;
                char c;
     
                /* Get final character of directory name */
                if (buffer < q) {
                    c = q[-1];
                } else {
                    c = ':';
                }
     
                /* Append directory separator if not already there */
                if (c != ':'  &&  c != '/'  &&  c != '\\') {
    #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
                    *q++ = '\\';
    #else
                    *q++ = '/';
    #endif
                }
     
                /* Append file name */
                src = ent->d_name;
                while (q < end  &&  *src != '\0') {
                    *q++ = *src++;
                }
                *q = '\0';
     
                /* Decide what to do with the directory entry */
                switch (ent->d_type) {
                case DT_REG:
                    /* Output file name with directory */
                    extName = strrchr(ent->d_name, '.');
                    if(extName == NULL) break;
     
                    if(strcmp(extName, ".txt") == 0)
                    {
                        //printf("fine txt file : %s\n", ent->d_name);
                        //printf ("%s\n", buffer);
                        enqueue(&mQueue, buffer);
                    }
                    break;
     
                case DT_DIR:
                    /* Scan sub-directory recursively */
                    if (strcmp (ent->d_name, ".") != 0  
                            &&  strcmp (ent->d_name, "..") != 0) {
                        find_directory (buffer);
                    }
                    break;
     
                default:
                    /* Do not device entries */
                    /*NOP*/;
                }
     
            }
     
            closedir (dir);
            ok = 1;
     
        } else {
            /* Could not open directory */
            printf ("Cannot open directory %s\n", dirname);
            ok = 0;
        }
     
        return ok;
    }
     
    void myDir(const char * dirPath)
    {
        DIR * dp;
        struct dirent * ent;
        char * extName;
     
        dp = opendir(dirPath);
        if(dp != NULL)
        {
            while(1)
            {
                ent = readdir(dp);
                if(ent == NULL)
                    break;
     
                extName = strrchr(ent->d_name, '.');
     
                if(strcmp(extName, ".txt") == 0)
                    printf("fine txt file : %s\n", ent->d_name);
            }
        } 
     
    }
     
    int IsAvailableEMail(const char * srcMail)
    {
        // 찾음 : 1
        // 없음 : 0
        
        int iAtCount = 0;   //@ 위치
        int iDotCount = 0;  // . 위치
        int i;
        char * eMail = (char*)malloc( strlen(srcMail) + 1 );
        strcpy(eMail, srcMail);
        
        if(strcmp(eMail, "") == 0)    return 0;
     
        
        for(i = 0; i < strlen(eMail); i++)
        {
            if(i > 0 && eMail[i] == '@' ) iAtCount = i+1;    // ①
            if(iAtCount > 0 && i > iAtCount && eMail[i] == '.') iDotCount = i+1;   // ②
        }
        free(eMail);
        if(i > iDotCount && iAtCount > 0 && iDotCount > 0) return 1;     // ③    
        else return 0;
    }
     
     
    int main()
    {
        //입력받은 디렉토리에서 확장자가 .txt인 파일을 찾고
        //큐에 넣은 후 이메일 주소를 뽑아내는 구조
     
        //큐 초기화
        FILE * fp;
        char buf[1024];
        char * path;
        const char * filePath;
        initQueue(&mQueue);
        
        //디렉토리 순회
        find_directory("C:\\Mail");
     
        ////제대로 나오는지 출력
        //while( !empty(&mQueue) )
        //{
        //    printf("%s\n", frontQueue(&mQueue));
        //    deQueue(&mQueue);
        //}
        //
     
        
        //찾은 파일을 열어서 이메일 주소를 확인
        while( !empty(&mQueue) )
        {
     
            path = frontQueue(&mQueue);
            filePath = path;
            fp = fopen(filePath, "r");
            if(fp != NULL)
            {
                int isEmail;
                char * ch;
                int i;
                //while(fgets(buf, 1024, fp))
                while( 0 < fscanf(fp, "%s", buf) )
                {
                    //printf("%s", buf);
                    isEmail = IsAvailableEMail(buf);
                    if(isEmail)
                    {
     
                        ch = strchr(buf, '"');
                        if(ch != NULL)
                            *ch = ' ';
     
                        ch = strchr(buf, '(');
                        if(ch != NULL)
                            *ch = ' ';
     
                        ch = strchr(buf, ')');
                        if(ch != NULL)
                            *ch = ' ';
     
     
                        printf("%s\n", buf);
                    }
     
                }
     
     
                fclose(fp);
                deQueue(&mQueue);
            }
        }
     
        destroyQueue(&mQueue);
        
     
        return 0;
    }


    이 게시물을 추천한 분들의 목록입니다.
    [1] 2013/12/23 22:44:10  210.218.***.54  밥이  233423
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    371726
    롯데카드 장기무이자 할부인데 [4] 오뚜기신라면. 24/09/28 12:06 431 0
    371725
    SSD 발열 스로틀링을 잡으려면 어딜 손 봐야 하나요 [5] ㅗㅠㅑ 24/09/22 08:31 488 0
    371724
    2100년까지 사용가능한 desktop pc [2] 김원표wonpyo 24/09/21 02:01 777 1
    371722
    모니터 사망 질문드립니다. [2] 십갱이 24/09/17 13:18 659 1
    371721
    둠은 고전게임인데 프레임이 높아서 어색하네요 ㅋㅋ [1] Oh_My!_Girl 24/09/17 12:05 734 1
    371720
    윈11 시스템 팝업창? 의 글자가 커졌으면 좋겠습니다. [4] 본인삭제금지 이사 24/09/14 23:07 719 0
    371719
    안녕하세요. 중고로 피시 구매할려고 합니다. [6] 단단a 24/09/14 08:09 750 1
    371718
    캔버스 키캡 설치 완료! [9] NeoGenius 24/09/13 15:20 758 3
    371717
    노트북 SSD 업글 질문 드립니다. [10] 베오베금지본인삭제금지 MincePie 24/09/13 14:01 605 0
    371716
    히히히~ 키캡 와써요~ 뿌잉뿌잉 [5] NeoGenius 24/09/12 16:22 709 4
    371715
    컴퓨터가 이상해요. [8] 굥정과상식 24/09/11 22:56 872 3
    371714
    안녕하세요 놋북추천해주시고 가시면 정말 감사합니다 [21] 본인삭제금지 이니예스타 24/09/10 14:57 762 10
    371713
    PC 조립비를 쓴 까닭 [13] NeoGenius 24/09/09 13:11 1284 9
    371712
    Lossless Scaling 이거 신세계네요..근데 OTT는 안되나요? [7] 본인삭제금지 Oh_My!_Girl 24/09/06 02:54 852 2
    371711
    전기누전후 컴퓨터가 안켜져요 [6] 꽃님이^^* 24/09/02 22:18 885 5
    371710
    폰으로 핫스팟으로 노트북게임하는데요.... [11] 별일없이산다 24/09/02 21:26 805 1
    371709
    커스텀 키보드 완료 [10] NeoGenius 24/09/01 01:51 915 4
    371708
    무뽑기 해보았습니다! [8] 캐타 24/08/29 23:17 917 3
    371707
    요새 컴터 업글 할 이유가 없네요 [4] 혹스터언 24/08/29 00:56 1233 4
    371705
    견적 한번 보시고 잔소리 해주세요 [10] 비니랑민아링 24/08/27 15:52 854 4
    371704
    조립컴 맞추신 분들 [14] 영기영차 24/08/26 11:19 1090 2
    371703
    커스텀 키보드 창작글 NeoGenius 24/08/23 20:17 801 1
    371702
    Hynix의 'H'는 Hyundai의 'H' [1] ㅗㅠㅑ 24/08/23 14:20 895 1
    371701
    제 컴퓨터에 윈도우즈11을 설치할 수 있는지 봐 주세요. [7] 미께레 24/08/23 13:19 954 1
    371699
    데스크탑 8년차 업그레이드 고민중입니다. [17] 창작글 캐타 24/08/22 00:04 1111 5
    371698
    하드디스크 추가로 장착하려는데요... 도움!! ㅠㅠ [6] 햄즈 24/08/21 22:28 808 0
    371697
    현시점 컴퓨터 구매에 대해 의견 부탁드립니다. [11] 순한사자 24/08/21 21:22 812 0
    371696
    당근에서 파는 중고 PC 봐주세요! [6] grcrewjp 24/08/21 13:06 1103 1
    371694
    네트워크 보안설정 802.1xEAP 이건 뭐에요?? [1] 잠이가온다 24/08/16 10:18 848 0
    371693
    인텔 13~14세대 CPU 이슈 [18] NeoGenius 24/08/14 17:18 1342 3
    [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [다음10개▶]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈