본문 바로가기
my_lesson/_C

C - Input output 표준 입출력

by boolean 2019. 3. 8.
728x90

#include <stdio.h>

#include <string.h>

#include <stdlib.h>


#define doSomethingElse(input) do{ printf("your input is %d\n", input); }while(0)


int main(void) {

int input, iInput[10];

int status, iNum;

char cInput1[50], cInput2[50];

// Identify wether it is a letter or a number

/*

while ((status = scanf("%d", &input)) != EOF) {

if (status == 0) {

printf("Not a number\n");

while (getchar() != '\n'); //clear input

}

else {

doSomethingElse(input);

printf("%d\n", status);

}

}

*/

// What is the different between fputs and printf

/*

fputs("Please enter string : ", stdout);

fgets(cInput1, 50, stdin);    // input with '\n' at the end

cInput1[strlen(cInput1) - 1] = NULL;   // replace last character with NULL

printf("Please enter string : ");

scanf("%s", cInput2);

puts(cInput1); // output with '\n' at the end

puts(cInput2);


fputs(cInput1, stdout); // output without '\n' at the end

fputs(cInput2, stdout);


printf("%s", cInput1); // output without '\n' at the end

printf("%s", cInput2);

*/


// What ist the diffrent between fgets and scanf

fputs("please enter number : ", stdout);

fgets(iInput, sizeof(iInput), stdin);

//scanf("%d", iInput+9);

//scanf("%d", iInput+8);

//iInput[9] = 33;

//atoi(iInput);

//printf("%d\n", iInput[9] + iInput[8]);

//puts(iInput);

fputs(iInput, stdout);



}


C++ 02.06 - 부동 소수점 숫자 (floating point numbers)  setprecision

출처: https://boycoding.tistory.com/152 [소년코딩]

https://boycoding.tistory.com/152

댓글