'분류 전체보기'에 해당되는 글 610건
045. 열거형 이해하기045. 열거형 이해하기
Posted at 2010. 11. 22. 04:24 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
enum { Sun=0, Mon, Tue, Wed, Thr, Fri, Sat };
main()
{
printf( "%d ", Sun ); // 0
printf( "%d ", Mon ); // 1
printf( "%d ", Tue ); // 2
printf( "%d ", Wed ); // 3
printf( "%d ", Thr ); // 4
printf( "%d ", Fri ); // 5
printf( "%d ", Sat ); // 6
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 047. 함수와 인수 이해하기 (0) | 2010.11.22 |
|---|---|
| 046. 데이터형 정의하기 (0) | 2010.11.22 |
| 044. 공용체 이해하기 (0) | 2010.11.22 |
| 043. 구조체 이해하기 (0) | 2010.11.22 |
| 042. 널(NULL) 문자 이해하기 (0) | 2010.11.22 |
044. 공용체 이해하기044. 공용체 이해하기
Posted at 2010. 11. 22. 04:20 | Posted in Computer/초보자를 위한 C 언어 300제#include <stdio.h>
union tagVariant
{
int i;
float d;
};
main()
{
union tagVariant V;
V.i = 0;
V.d = 5.5;
printf( "V.i = %d\n", V.i ); // V.i = 1085276160
printf( "V.d = %d\n", V.d ); // V.d = 5.500000
}
책에는 "V.d" 인데 오타인것 같다. 정상적인 출력은 printf( "V.d = %f\n", V.d ); 일 것이다.
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 046. 데이터형 정의하기 (0) | 2010.11.22 |
|---|---|
| 045. 열거형 이해하기 (0) | 2010.11.22 |
| 043. 구조체 이해하기 (0) | 2010.11.22 |
| 042. 널(NULL) 문자 이해하기 (0) | 2010.11.22 |
| 041. 포인터 이해하기 (0) | 2010.11.13 |
043. 구조체 이해하기043. 구조체 이해하기
Posted at 2010. 11. 22. 04:16 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
struct tagSungJuk
{
int kor;
int eng;
int math;
};
main()
{
struct tagSungJuk SJ;
SJ.kor = 100;
SJ.eng = 95;
SJ.math = 99;
printf( "총합 = %d", SJ.kor + SJ.eng + SJ.math );
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 045. 열거형 이해하기 (0) | 2010.11.22 |
|---|---|
| 044. 공용체 이해하기 (0) | 2010.11.22 |
| 042. 널(NULL) 문자 이해하기 (0) | 2010.11.22 |
| 041. 포인터 이해하기 (0) | 2010.11.13 |
| 040. 메모리 이해하기 (0) | 2010.11.13 |
042. 널(NULL) 문자 이해하기042. 널(NULL) 문자 이해하기
Posted at 2010. 11. 22. 04:13 | Posted in Computer/초보자를 위한 C 언어 300제#include <stdio.h>
int length( char* pstr );
main()
{
int len = length("abcde");
printf( "길이 = %d", len); // 길이 = 5
}
int length( char* pstr )
{
int len = 0;
while( *pstr != NULL )
{
pstr++; // pstr의 번지를 1만큼 증가
len++; // 문자열의 길이를 1만큼 증가
}
return len;
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 044. 공용체 이해하기 (0) | 2010.11.22 |
|---|---|
| 043. 구조체 이해하기 (0) | 2010.11.22 |
| 041. 포인터 이해하기 (0) | 2010.11.13 |
| 040. 메모리 이해하기 (0) | 2010.11.13 |
| 039. 배열 이해하기 (0) | 2010.11.13 |
041. 포인터 이해하기041. 포인터 이해하기
Posted at 2010. 11. 13. 23:48 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
main()
{
int saram_A = 0;
int saram_B = 0;
int* pointer;
int* psaram;
pointer = &saram_A;
*pointer = 1;
printf( "%d, %d\n", saram_A, *pointer ); // 1, 1
psaram = &saram_A;
*psaram = 2;
printf( "%d, %d, %d\n", saram_A, *pointer, *psaram ); // 2, 2, 2
pointer = &saram_B;
*pointer = 3;
printf( "%d, %d, %d\n", saram_A, saram_B, *pointer ); // 2, 3, 3
psaram = &saram_B;
*psaram = 4;
printf( "%d, %d, %d, %d\n", saram_A, saram_B, *pointer, *psaram ); // 2, 4, 4, 4
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 043. 구조체 이해하기 (0) | 2010.11.22 |
|---|---|
| 042. 널(NULL) 문자 이해하기 (0) | 2010.11.22 |
| 040. 메모리 이해하기 (0) | 2010.11.13 |
| 039. 배열 이해하기 (0) | 2010.11.13 |
| 038. 문자열 이해하기 (0) | 2010.11.13 |
040. 메모리 이해하기040. 메모리 이해하기
Posted at 2010. 11. 13. 23:43 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
main()
{
int i = 0;
int j = 1;
printf( "값=%d, 메모리주소=%p\n", i, &i ); // 값=0, 메모리주소=0012FF7C
printf( "값=%d, 메모리주소=%p\n", j, &j ); // 값=1, 메모리주소=0012FF78
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 042. 널(NULL) 문자 이해하기 (0) | 2010.11.22 |
|---|---|
| 041. 포인터 이해하기 (0) | 2010.11.13 |
| 039. 배열 이해하기 (0) | 2010.11.13 |
| 038. 문자열 이해하기 (0) | 2010.11.13 |
| 037. 무조건 분기문 이해하기 (0) | 2010.11.13 |
039. 배열 이해하기039. 배열 이해하기
Posted at 2010. 11. 13. 23:41 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
main()
{
int kor[10] = {100, 90, 35, 60, 75, 55, 95, 80, 90, 70};
int i;
for( i = 0; i < 10; i++ )
{
printf( "%d ", kor[i] );
}
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 041. 포인터 이해하기 (0) | 2010.11.13 |
|---|---|
| 040. 메모리 이해하기 (0) | 2010.11.13 |
| 038. 문자열 이해하기 (0) | 2010.11.13 |
| 037. 무조건 분기문 이해하기 (0) | 2010.11.13 |
| 036. 조건 순환문 이해하기 2(do~while~continue~break) (0) | 2010.11.13 |
038. 문자열 이해하기038. 문자열 이해하기
Posted at 2010. 11. 13. 23:38 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
#define ASCII_BEGIN 0
#define ASCII_END 255
main()
{
int i;
for( i = ASCII_BEGIN; i <= ASCII_END; i++ )
{
printf( "ASCII 코드 (%3d), 문자 = '%c'\n", i, i );
}
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 040. 메모리 이해하기 (0) | 2010.11.13 |
|---|---|
| 039. 배열 이해하기 (0) | 2010.11.13 |
| 037. 무조건 분기문 이해하기 (0) | 2010.11.13 |
| 036. 조건 순환문 이해하기 2(do~while~continue~break) (0) | 2010.11.13 |
| 035. 조건 순환문 이해하기 1(while~continue~break) (0) | 2010.11.13 |
037. 무조건 분기문 이해하기037. 무조건 분기문 이해하기
Posted at 2010. 11. 13. 23:35 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
main()
{
int i;
int j;
for( i = 1; i <= 100; i++ )
{
for( j = 1; j <= 99; j++ )
{
printf("%d * %d = %2d\n",i,j, i*j );
if( i == 9 && j == 9 ) goto ku_ku_end;
}
}
ku_ku_end:;
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 039. 배열 이해하기 (0) | 2010.11.13 |
|---|---|
| 038. 문자열 이해하기 (0) | 2010.11.13 |
| 036. 조건 순환문 이해하기 2(do~while~continue~break) (0) | 2010.11.13 |
| 035. 조건 순환문 이해하기 1(while~continue~break) (0) | 2010.11.13 |
| 034. 조건 선택문 이해하기(switch~case~default) (0) | 2010.11.13 |
036. 조건 순환문 이해하기 2(do~while~continue~break)036. 조건 순환문 이해하기 2(do~while~continue~break)
Posted at 2010. 11. 13. 23:33 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
main()
{
int i = 1;
int hap = 0;
do
{
hap = hap + i;
i++; // i는 1,2,3,4,5,6,7,8,9,10,11까지 증가
} while( i <= 10 ); // i가 10보다 작거나 같은 동안 반복, 11이면 순환 탈출
printf( "hap = %d",hap ); // hap = 55
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 038. 문자열 이해하기 (0) | 2010.11.13 |
|---|---|
| 037. 무조건 분기문 이해하기 (0) | 2010.11.13 |
| 035. 조건 순환문 이해하기 1(while~continue~break) (0) | 2010.11.13 |
| 034. 조건 선택문 이해하기(switch~case~default) (0) | 2010.11.13 |
| 033. 중첩 순환문 이해하기(for~continue~break) (0) | 2010.11.13 |
