반응형
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
// malloc.cpp: 콘솔 응용 프로그램의 진입점을 정의합니다.
//
 
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int i = 0;
    char str[255];
    /* // scanf의 경우 스페이스를 구분지어 입력됨.
    while (scanf_s("%d", &i) != EOF) {
        printf("%d가 입력되었습니다.\n", i);
        i++;
    }*/
    /* // gets는 스페이스를 구분 짓지 않음.
    while (gets_s (str) ){
        printf("%s가 입력되었습니다.\n", str);
        i++;
    }*/
    // atoi함수 -> #include <stdlib.h> 에 들어 있음.
    while (gets_s(str)) {
        int j = atoi(str);
        printf("%d 가 입력되었습니다. \n",j);
        //예 ) 계산기 문제 
        // scanf_s("%s", &str);
        // if (strcmp(str,"*")) // strcmp 비교
    }
    
    printf("EOF 입력됨");
    return 0;
}
 
 
cs
반응형

'Study > C' 카테고리의 다른 글

C언어 - 자판기  (0) 2018.09.14
C언어 - 포인터 이해  (0) 2018.09.07
C언어 - 학생 Table(총점, 평균, 석차)  (0) 2018.09.07
C언어 - 탐색, 정렬, 순위  (0) 2018.09.07
C언어 - Stack으로 구현한 자동차 주차장  (0) 2018.09.06

+ Recent posts