Search

Theseus

C Language - Output Sentence - Source Code 08


기본 출력 1 [\n \t]
Introduction
다음을 출력하는 프로그램을 작성하시오.
hello
there
sky
Source Code
#include <stdio.h>

int main(void)
{
     printf("hello\n"); //enter
     printf("there\n"); //enter
     printf("sky\n"); //enter
     return 0;
}
실행결과
hello
there
sky
Review
printf("hello\n"); 처럼 빈칸도 출력되는가?
빈칸을 넣으면 빈칸도 출력됩니다.
기본 출력 2
Introduction
다음과 같이 출력하는 프로그램을 작성하시오.
Hi my name is     Ko Sang Kyu
How are you?
Source Code 1
#include <stdio.h>

int main(void)
{
     printf("Hi my name is     Ko Sang Kyu\n");
     printf("How are you?\n");
     return 0;
}
Source Code 2
#include <stdio.h>

void main()
{
     printf("hello\thello\n"); // \t = tab
     printf("hello\n"); //enter
}
실행결과
Hi my name is     Ko Sang Kyu
How are you?
gcc compiler Font Color Output
Source Code
#include <stdio.h>

int main()
{
     printf("%c[0moriginal color\n",27);
     printf("%c[31mred color\n\n",27);  //두칸 띄기
     printf("%c[32mgreen color\n",27);
     printf("%c[33myellow color\n",27);
     printf("%c[34mblue color\n",27);
     printf("%c[35mviolet color\n",27);
     printf("%c[36mviolet color\n",27);
     return 0;
}
Review
Eclipse에서는 글자색이 변하지 않는다.
이때는 결과의 확인을 위해서 Cygwin Terminal을 이용한다.

No comments:

Post a Comment