#include<stdio.h>
int main()
{
do
{
}While();//()안이 조건
return 0;
}
한번 실행하고 조건을 본다.
---------------------------------------------------------------------------------------------
while을 for문으로
(while문)
#incldue<stdio.h>
int main()
{
int iCnt;
iCnt = 1;
while(10>iCnt)
{
printf("3X%d=%d", iCnt, 3*iCnt);
iCnt = iCnt+1;
}
return 0;
}
(for문)
#include<stdio.h>
int main()
{
int iCnt
for(iCnt+1; 10>iCnt; iCnt = iCnt+1;)
{
printf("3X%d=%d", iCnt, 3*iCnt);
}
return 0;
}
------------------------------------------------------------------------------------
반복문(for문을 이용)
(무한반복문)
#include<stdio.h>
int main()
for( ; ; ) = while(1)
{
for(iCnt = 0; 100000000>iCnt; iCnt=iCnt+1)//iCnt=iCnt+1 = ++iCnt, iCnt++
{}
printf("test\n");
}
(지연반복문)
#include<stdio.h>
int main()
{
volatile int iCnt;
for( ; ; )
{
for (iCnt=0; 100000000>iCnt; iCnt= iCnt+1)
{}
printf("test\n");
}
return 0;
}
---------------------------------------------------------------------------------------------------------
위의 iCnt=iCnt+1 = ++iCnt, iCnt++에 대하여
++iCnt->iCnt=iCnt+1; A=iCnt->iCnt가 아직 결정되지 않았지만 +1을 한다.A가 100이것이 iCnt에 들어가 +1한 101을 A가 가지게된다.
iCnt++->A=iCnt; iCnt=iCnt+1->A가 100을가진다 그다음 +1을 한다.
(여기부분 갑자기 잘 기억이 안나네요)
---------------------------------------------------------------------------------------------------------
유니온과 스트럭트
#include<smart.h> struct smart { int A; short B; int C; char D; } int main() { printf("size of smart:%d\n", sizeof(struct smart); return 0; } |
#include<smart.h> union smart { int A; short B; int C; char D; } int main() { union smart obj; obj.A=0x12345678; obj.B=0x12345678; obj.C=0x12345678; obj.D=0x12345678; printf("size of smart:%d\n", sizeof(union smart); printf("A=[%X]\n",obj.A); printf("B=[%X]\n",obj.B); printf("C=[%X]\n",obj.C); printf("D=[%X]\n",obj.D); return 0; } |
size of smart:16 |
size of smart:4 A=12345678 B=5678 C=12345678 D=78 |
78 |
56 |
34 |
12 |
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
20160309_장진웅_업무일지_CPu모듈 (2) | 2016.03.09 |
---|---|
20160309-조재찬-업무일지-CPU 모듈 (3) | 2016.03.09 |
16.03.09 조승현 업무일지 <AT mega2560 *소프트웨어*>2/2 (2) | 2016.03.09 |
16.03.09 조승현 업무일지 <AT mega2560 *하드웨어*>1/2 (2) | 2016.03.09 |
20160309_오아람_업무일지_그 밖에 기초학습 (2) | 2016.03.09 |
MIT 양자컴퓨터…암호화 종말? (0) | 2016.03.09 |
20160308_김가연_제어언어 그밖의 기초학습 (2) | 2016.03.09 |
20160308 _정일모 그 밖의 기초학습 (2) | 2016.03.09 |