c언어 강좌! 세번째 장 / C language course! The third chapter

in #kr7 years ago

안녕하세요 요즘 다른 작업에 빠져사느라 늦었네요

시험기간에는 스팀잇에 강좌 올릴 생각만 했었는데

막상 시험이 끝나니까 생각도 안나네요 하하

이번 시간에는 지난 시간에 배운 출력에 대해서 좀 더 깊게 알아볼건데요

지난번에 배운 'printf'라는 함수에는 서식문자라는 것이 있습니다

자 다시 한 번 Dev c++을 켜볼까요?

1.png

이런 식으로 한 번 코드를 짜봅시다

실행해 볼까요??

2.png

이런 결과가 나오네요

자 그럼 해석 들어갑니다!!

%d, %lf, %s, %c 이상한 것들이 들어갔죠?

이것들이 의미하는 것을 알아볼게요

우선 이것들은 통칭 서식문자라고 합니다

말 그대로 서식한다는 것인데 따옴표 뒤에 숫자랑 문장들 넣으신거 보이죠?

그 뒤에있는 값을 받아와서 출력을 한다는 의미에요

printf는 ()안에있는 첫번째 ""내용을 출력하는데 %d를 예로들면
printf("%d\n",10)은 %d가 10값을 가져서 printf("10\n")과 같은 역할을 하게 되는겁니다

나머지도 다 알겠죠? 그럼 이제 저 %뒤에붙는 문자의 의미를 알아볼까요?

서식문자는 자기가 받는 값의 형식이 정해져있어요

%d는 1,2,3,10,51515같은 정수, %lf와 %f는 1.51, 814.215같은실수(%lf와 %f의 차이점은 뒤에서 변수를 배우면서 알려드릴 겁니다)
%c는 'A', 'B', 'a'같은 문자
%s는 "hello world", "Im apple"같은 문장을 받는다고 의미합니다.

그리고 뒤에 \n이 뭔지 궁금해하시는 분들이 많은데

보통 키보드 자판 백스페이스바 옆에는W모양이 있죠?

글꼴에 따라 \가 되는데 둘다 같게 쓰이고요 \n을 하면 행넘김
엔터를 눌렀을 때와 같은 효과가 콘솔창에 일어납니다

한 번 \n을 빼놓고 해보시면 차이점을 아실거에요 ㅎㅎ

오늘 강좌는 여기까지! 다음 시간에는 연산자를 배워볼거에요

그럼 다음에 봅시다 뿅~!

Hello. It's late for you to get into another job these days.

During the test, I was just thinking about lecturing Steamit.

I do not even think about it because the test is over.

This time, I'll take a closer look at the output you learned last time.

The function called 'printf' we learned last time has a formatting character

Let's turn on Dev c ++ again.

1.png

Let's code this once.

Let's try it ??

2.png

Well then, interpretation goes in !!

%d, %lf, %s, %c Strange things got in?

I'll see what these mean.

First of all, these are called generic formatting characters

It means literally formatting . Do you see the numbers and sentences after the quotes?

It means to take the value after it and print it.

printf prints the first "" contents in parentheses, using% d as an example
printf ("%d \ n", 10) will act like printf ("10 \ n") because% d has a value of 10

You know all the rest? So now let's look at the meaning of the character that follows the%.

The formatting letter has the format of the value it receives.

%d is an integer like 1,2,3,10,51515, %lf and %f are real numbers like 1.51, 814.215 (the difference between %lf and %f will be explained later by learning the variable)
%c is a character such as 'A', 'B', 'a'
%s is a sentence like "hello world", "Im apple".

And there are a lot of people wondering what \ n is behind it.

Is there a W shape next to the backspace bar?

Depending on the font, \ is used, and both are used the same.
The effect is the same as when you hit Enter.

Once you have removed \n, you'll notice the difference.

Today's lecture is here! Next time we'll learn the operator.

Let's see next time~!

Sort:  

뉴비는 언제나 응원!이에요.
팁! : @randowhale이라는 사람은 일종의 복권이에요 2SBD와 게시글링크를 메모로 보내면 당신에게 1~5%보팅을 해주죠, 주의! SBD만 냠냠하는 짝퉁도 있으니 조심하세요.
20.83% 보팅
현재 보상량 : [ 평균 - 0.85 / 1개 / 합계 : 0.85 ]

  • kr-newbie 보안관 봇! (beta 0.5.0 - 2017/07/17)

Congratulations @schch020! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @schch020! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65373.54
ETH 2639.03
USDT 1.00
SBD 2.84