매크로 함수

Programming/C Language 2009. 8. 18. 23:02
매크로 함수 호출문에서는 ++, -- 등의 증감 연산자나 +=, *= 등의 복합 대입 연산자는 쓰지 않는 것이 좋다.


#define dubae(i) ((i)+(i))

void main()
{
   int k,j;
   k = 3;
 
   j= dubae(k++);
}


이라고 쓰게 되면 j에는 6이 출력 되고, k는 5가 된다. 왜냐하면 매크로 함수를 호출하게 되면
( (3++) + (3++) ) 로 치환이 되기 때문이다.



#define abc()\
{ a();\
   b();\
   c(); }


매크로가 길 경우에는 \ 를 써서 여러줄로 쓸수 있다.


#define VALUE 1000
#define VALUE2 VALUE+100


이때 VALUE2 * 2 를 하게 되면 결과는 .. 2200 이 나올까? 그렇지 않다. 결과는 1200 이다.
그 이유는 VALUE2 가 VALUE+100 으로 치환되어서 VALUE+100*2 가 되어서 결과는 1200이다.
이런 경우  ( VALUE + 100 ) 로 묶어 주어야 한다.


출처 : www.winapi.co.kr

'Programming > C Language' 카테고리의 다른 글

구조체 정렬  (0) 2009.09.27
#include 와 #define 의 순서  (0) 2009.08.18
코딩 스타일  (0) 2009.08.15
#ifndef ~ #define ~ #endif  (0) 2009.08.15
헤더파일과 소스파일  (0) 2009.08.02

설정

트랙백

댓글

[Grammar in use Inter] UNIT 31 ~ 40

English/Grammar 2009. 8. 18. 22:38
UNIT31
It should be 1.29 dollars. ( 가격이 다름 - 이게 맞는데 지금 그렇지 않기 때문에 이야기 함 )
She should be here by now. ( 지금 여기에 없음 )
should have done something = u didn't do it but it would have been the right thing to do
~ 했어야 했는데...( 하지는 않았지만 하는 것이 맞는 것일 때 )
ought to = should


UNIT32
suggest, propose, recommend, insist, demand
+ ( that ) S + (should) +  V ( 항상 동사 원형을 사용 - 시제에 관계없이( 과거, 현재, 미래 ) )
여기서 미국에서는 should 는 생략 함. 영국에서는 should 사용

ex ) I insist (that) you come with us.
       I insisted (that) you come with us.

부정형에서...
should 를 생략하고, I not be, you not leave, she ( should ) not go, etc )

수동형에서... be 를 사용
I insisted (that) something be done about the problem.

suggest 다음에는 to 부정사 를 사용하지 않는다.
What do you suggest I do? ( not suggest me to do )


UNIT33
Had better : (특별한 경우에) 이렇게 하는게 낫다. - 하지 않을 경우에 문제가 있거나 위험 )
should : (일반적인 경우에) 이렇게 하는게 낫다.

It's time ( for somebody ) to do something.
= It's time (that) somebody V-ed something. - 비평할 때나 불평 할 때 사용. ( 이미 됐어야 하는 상황 , you should have done it already or started it. )

ex ) It's time ( for us ) to go.
       It's time he got up.
       It's time the children were in bed.

It's about time ... ( 비평을 강조 할 때 - 이제는 정말 ~ 해야 할 때 아니냐...?( 짜증스럽게 들림 ) )
ex ) it's about time he did something instead of just talking.


UNIT35
If I V , ~      : 미래를 기준으로 말함
If I V-ed, ~  : 지금을 기준으로 당장에...

Would you mind if I V-ed ~?


UNIT36
I wish I V-ed ~ : ( regret something ), 아쉬움이 강함( 안되는 것 )
ex ) I wish I knew Paul's phone number. ( =  I don't know it and I regret this )
       I wish I had an umbrella.
       I wish I were a birad.


UNIT37
If I had V-ed ~, I would ~ : ( 과거를 기준으로 ) ~ 하지 않았더라면, ~ 했을 거다.( 실제로 함 )
ex ) If I hadn't broken up with my first girl friend, I would have a son of ur age.

I wish I had p.p : 과거에 ~ 하지 않았더라면... ( 실제로 함 - 후회함 )
I feel sick. I wish I hadn't eaten so much cake.( I ate too much cake )


UNIT38
hope - 미래에 대한 희망
ex ) I hope you get better soon.

wish : 불평하면서 바꼈으면 하는 것
I wish I would V ~ : ~ 했으면 ... ( 행동이나 변화에 대해서 사용 )
I wish it would stop raining. 비 좀 그만 왔으면...

I wish someone V-ed.. ( 상황 situation )
ex ) I wish Shara were here now.
       I wish I had a car.

설정

트랙백

댓글

[News] Seoul Confirms 76 More Flu Cases After 2 Deaths

English 2009. 8. 18. 12:07
South Korea's health ministry Monday confirmed 76 more cases of influenza A amid growing concerns about the spread of the contagious disease(전염병) after two deaths from the virus were reported over the weekend.

The new patients, including a high-school athlete and three people participating in an international event on the southern island of Jeju, tested positive(양성반응을 일으켰다) for the H1N1 virus, according to the ministry.

The new patients brought the total number infected with the global pandemic( 세계적인 유행병 ) to 2,165 in South Korea since it was first reported in early May. Most of them showed mild symptoms and recovered fully, with 480 still being treated at home or in hospitals, the ministry said.

Two Koreans died Saturday and Sunday from complications(합병증) apparently caused by the flu virus, which has claimed the lives of almost 1,500 people across the world. One of the two was in his 50s and the other in her 60s.

South Korea has been relatively safe from the pandemic but infections are feared to accelerate as students staying overseas for language training or short-term trips return home as the summer vacation period draws to(~에 다가가다) an end. They could infect other classmates and family members, experts say.

As the spread of the contagious disease quickens, the Seoul government plans to supply antiviral(항바이러스의) drugs, including Tamiflu, which could treat 5.31 million patients, to public health centers(보건소) nationwide(전국적으로, 전국적인).

'English' 카테고리의 다른 글

[Grammar in use Inter] UNIT 41 ~ 50  (0) 2009.08.19
[News] Refugee Status  (0) 2009.08.19
[Writing] 2  (0) 2009.08.13
[Writing] 1  (1) 2009.08.12
[Grammar] whoever, whomever 차이  (0) 2009.06.23

설정

트랙백

댓글

[ POWER ENGLISH ] 2004-03-06

English/EBS 2009. 8. 18. 03:24
take advantage of ~ = 긍정문으로도 사용
use ~ = manipulate( 사람, 여론 등을(부정하게) 조종하다, 이용하다 )
exploit = 착취하다( 가장 심한 표현 )

sweat shop
착취 공장( 저임금으로 노동자를 장시간 혹사 시키는 )

chicken feed
껌 값, 잔돈, 푼돈


exploit


환경을 부당하게 이용하는 자들은, 사람들이 아무 행동도 하지 않을 것이라고 믿는다.
Those who exploit the environment counts on people doing nothing.

그들이 우리의 이용하도록 내버려 두면 안된다.
We shouldn't let them exploit our resources.


conducive to

How can you work under these conditions?
직원들에게 전혀 좋지 않다
The condition is not conducive to workers.

직원들에게 좋은 환경을 만들어야 한다.
We must create an environment conducive to employees.

이 교육 시설들은 교육 증진에 이바지하는 시설이 아니다.
These learning facilities are not conducive to education.

음주와 흡연은 건강에 좋지 않다.
drinking and smoking are not conducive to good heath.


take place

내가 없을 때 무슨 일 있었나?
Did anything unusual take place while I was away?

그 사고는 밤 12시가 지나자 마자 일어났다.
The accident took place just past midnight.

지난 밤에 뭔 일 있었어?
Did sth take place last night?


encircle
= to make a circle = surround


난 그의 손이 내 어깨를 감싸는 것을 느꼈다.
I felt his hands encircle my sholder

빛나는 다이아몬드 팔찌가 그녀의 손목을 감싸고 있었다.
A shimmering diamond braclet encircled her wrist.

달은 지구 주위를 돈다.
The moon encircles the earth.

야자나무들이 호텔을 에워싸고 있다.
Palm trees encircle the hotel.


not like someone to~

그녀 답지 않는데...( 그녀는 보통 늦지 않는데... )
It's not like her to be late.

바람 맞추다.
stand up = blow someone off

나 바람 맞았어.
I've got stood up.

그녀는 화를 낼 사람은 아닌데.
It's not like her to blow her top.

뚜껑이 열리다.
blow one's top

설정

트랙백

댓글

[Grammar in use Inter] UNIT 21 ~ 30

English/Grammar 2009. 8. 18. 02:34
UNIT22
will : (징조 는 없고, 그냥 생각 )
is going to : ( 징조가 보일 경우 )


UNIT23
Will you be -ing...? = to ask about somebody's plans, especially if you want something or want them to do something. 부탁을 할 때...
Will you be using your car tonight? 오늘 밤에 차 쓸거냐?
will have done : 미래에 특정 시점에 이미 다 했을 꺼라고 할 때 사용.

until : ~까지. ~까지 지속됨, 그때 딱 끝남
by : ~까지, ~이전에 끝남.


UNIT24
When I've done~ = After I do / After I've done ....
ex ) When I've called Kate, we can have dinner. Kate랑 전화가 끝나면 먹겠다( 순서가 명확 )
      When I call Kate, we can have dinner. 전화 하는 도중인지, 다 하고 난 뒤인지 순서가 명확하지 않음


UNIT25, 26
have been able to ~ ( ~ 할 수 있었다 )
could have done - ( ~ 할 수 있었는데 실제로 하지 못함, 일어나지 않음 ) - it was possible, but didn't happen

stand on my head 물구나무 서다.
get away 달아나다
manage to 어떻게든 ~하다

have monday afternoon off. 월요일 오후에 쉬었다.


UNIT27
must have been (a) / -ing / p.p  ( 틀림없이 ~ 했을 꺼야. )


UNIT28
might have been ( 그랬었을 지도 모른다 ) must 보다 약한 추측


UNIT29
I'll be watching 아마 ~ 하고 있을 꺼다
I might be watching 아마 ~ 하고 있을 꺼다 (약한 추측)
I might as well go now 뭐 그냥 가지뭐 ( 별 특별한 방법이 없을 때 )

설정

트랙백

댓글

[Grammar in use Inter] UNIT 11 ~ 20

English/Grammar 2009. 8. 16. 18:07
UNIT12
When ~ ? : 특정 시점을 찝어주는 표현( + simple past ) ( have pp 는 사용할 수 없음 )


UNIT13
I lost my key. ( 예전에 이미 잊어버렸고, 지금 아무 영향을 미치지 않음 )
I've lost my key. ( 키를 잊어버려서 지금 집에 못 들어가고 있는 상황... )


UNIT17
I didn't use to like him( 그를 좋아하지 않았었다 ) 과거 : 안그렇다. 현재 : 그렇다.
Did you use to eat a lot of candy when you were a child? 어릴 때 사탕 많이 먹고 그랬었나? ( 현재 : 안 그럼 )

I used to live alone. ( = I lived alone in the past, but I no longer live alone )
I'm used to doing ( 혼자사는데 익숙하다 )


UNIT18
Timetables, schedules - 미래라도 현재형을 사용
What time does the plane leave tomorrow?
= What time are you leaving tomorrow?


UNIT19
I was going to do something = I intended to do it but didn't do it. 하려고 했으나 하지 않았다.
 ex ) We were going to travel by train, but then we decided to drive instead.

something is going to happen in the future = the situation now makes us believe this.
 ex ) He is going to fall into the hole. ( 그 사람이 구멍에 곧 빠질 것 같은 상황으로 보일 때 )

설정

트랙백

댓글

[Grammar in use Inter] UNIT 1 ~ 10

English/Grammar 2009. 8. 16. 17:40
UNIT4
thinking : 누군가가 생각하는 것을 직접 볼 수 있을 경우
I'm not growing vegetable this year : 올해만 안 기른다( 이전에도 했었다, 나중에도 할 수 있다 )

UNIT5
Did you go to R + 특정 시점 ?
Have you been to ~ ?

UNIT7
Why did you drop? 왜 (수업)취소 했노?

I drank 10 cups of coffee. : 과거에 커피 10잔을 마셨다.( 이미 끝난 상황 )
I've drunk 10 cups of coffee today. : 오늘 10잔 마셨다( 더 마시게 되면 변화가 가능한 경우 )

I never met my father. 더 이상 만날 수 없는 경우( 돌아가셨을 경우 )
I've never met my father. 나중에 만날 수도 있다.( 가능성이 있는 경우 )

UNIT8
I lived in London for 3 years.( 예전에 살았었다 )
I've livend in London for 3 years. ( 지금도 살고 있는 경우 )



설정

트랙백

댓글

코딩 스타일

Programming/C Language 2009. 8. 15. 18:08
버그가 생기지 않는 코딩 습관

1. 하나의 지역 변수를 여러 용도로 사용하지 말 것

2. 함수의 인자를 다른 목적으로 이용하지 말 것

3. malloc() 과 free()는 서로 가까이 둘 것
   - malloc()에 대응하는 free() 의 대응 관계가 명백하게 보이도록 소스코드를 작성하는 것이 좋다.
     초기화 함수에서 malloc()으로 메모리를 할당한다면, 종료 처리 함수를 두어 free() 하는 코드를 작성

4. 구조체는 생성과 동시에 초기화하라
   - 구조체에 메모리의 할당과 멤버초기화 하는 함수를 두는 것이 좋다.
   - 구조체의 초기화는 memset 을 사용 struct pointer *p; memset( p, 0, sizeof( *p ) );
      주의 : sizeof( p ) 를 사용할 경우 4바이트 만 초기화 됨

5. 포인터는 NULL 로 초기화 하라

6. 점검하기 쉬운 스타일을 취할 것
    int get_x_value( const struct point *p          ) ~;
    int set_x_value(          struct point *p, int x  ) ~;


버그가 발생했을 때 대처하기 쉬운 코딩 스타일

1. 반납한 포인터는 NULL로 리셋
    - 반환한 메모리에 접근해서 프로그램이 죽는다. ( OS에서 잘못된 참조 오류가 발생하여 프로세스가
      중단 or 시스템이 중단 되도록 고안 )
    - 해제 이전에 메모리 체크 ( 이와 같은 스타일은 항상 일관되게 작성 하도록 한다 )
    if( p->name )
       free( p->name );
    else
       fprintf( stderr, "p->name is NULL.\n");

2. 함수의 앞부분에서 인자를 검사할 것
    - 각 인자가 NULL 인지 체크하기


추격을 위한 코딩 스타일


1. 함수는 가급적으로 한 줄에 다 적어라
- 함수가 길어질 경우,함수 선언을 여러줄에 나누어 쓰게 되는데 grep로 검색할 경우 한 줄 씩 보여주므로
  함수의 원형을 한번에 볼수 없다.


수정과 확인이 쉬운 코드
1. 중괄호를 생략하지 말 것

2. return을 한 군데로 몰아둘 것
   func()
   {
      int return_value;
      return_value = -1;
      return (return_value);
    }
    와 같이 중간에 여러 조건 검사가 있고 return을 해야 할 경우 return value 값을 바꿔주기만 하고
    함수마지막에 이를 호출 할 것

'Programming > C Language' 카테고리의 다른 글

#include 와 #define 의 순서  (0) 2009.08.18
매크로 함수  (0) 2009.08.18
#ifndef ~ #define ~ #endif  (0) 2009.08.15
헤더파일과 소스파일  (0) 2009.08.02
모듈화 프로그래밍 - 2  (0) 2009.06.28

설정

트랙백

댓글

#ifndef ~ #define ~ #endif

Programming/C Language 2009. 8. 15. 17:15
#ifndef _LIBRARY_H_
#define _LIBRARY_H_

( 헤더 파일 본문 )

#endif

와 같이 헤더파일에 쓰면 헤더 파일 본문이 여러 번 반복되지 않도록 해준다.
_LIBRARY_H_( _파일명_확장자명_ ) 는 꼭 저렇게 쓸 필요는 없지만 파일마다 해깔리거나 중복될 염려가 없다. 처음 library.h를 인클루드 할 때 _LIBRARY_H_ 가 정의되지 않았으므로, _LIBRARY_H_ 를 정의하고, 헤더파일 아래를 인클루드한다. 그리고 다음번에 library.h를 인클루드 할 때 _LIBRARY_H_ 가 정의 되어 있으므로, #ifndef 아래의 문장들은 무시하고 넘어가게 된다.

'Programming > C Language' 카테고리의 다른 글

매크로 함수  (0) 2009.08.18
코딩 스타일  (0) 2009.08.15
헤더파일과 소스파일  (0) 2009.08.02
모듈화 프로그래밍 - 2  (0) 2009.06.28
모듈화 프로그래밍 - 1  (0) 2009.06.28

설정

트랙백

댓글

[ POWER ENGLISH ] 2004-03-05

English/EBS 2009. 8. 13. 13:46
hit it off with someone from the start.
~와 잘 맞다.


kiss and tell
이성과 어떤 일이 있었다는 것을 말하는 것을 말한다.


love at first sight
첫 눈에 반하다


chemistry
궁합


how far did you guys get? first base? second base?
asking about a progress of relationship. 어디까지 갔어? ( 애인과의 진도를 물어봄 )


let the cat out of the bag
= i'm not going to tell you a secret. 비밀을 털어놓다.


It's not like someone( to do sth )
그 사람이 원래 그렇지 않다. ( ~하지 않는데 ... 왜 그런지 모르겠다 )


punctual
시간[기한]을 엄수하는, 시간을 잘 지키는


get wasted
= get drunk 술 취했다.


set the alarm
알람을 맞추다


go off
(알림이) 울리다


massive hangover
숙취


kick that habit of doing sth[ getting drunk ]
stop doing sth( bad habit ) 술취하는 버릇 고쳐야한다.


It's easier said than done
말은 쉽지.


likewise
me too. same here


I've heard so much about you from someone.
~로 부터 당신에 대해 많이 들었어요.


set you up with one of my buds
내 친구중 한명을 소개시켜주다.


왜 알람이 안울렸지?
why didn't the alarm go off?

내 알람은 매일 아침 6시에 정확히 울린다.
My alarm clock goes off  at exactly 6 every morning.

오늘 아침에 알람이 울리는 것을 못들었다.
I didn't hear the alarm clock going off this morning


sunday driver
일요일만 운전하는 사람

설정

트랙백

댓글