연습문제만-수정

Size: px
Start display at page:

Download "연습문제만-수정"

Transcription

1 10 Call by Value Call by Reference Call by Result Call by Name C call by value void int X int hap(int x, int y, int z, int w); printf("%d\n", hap(3, 4, 5, 6)); int hap(int x, int y, int z, int w) return x+y+z+w; main X 01 int expo(int a, int b) int i,s=1; 04 for(i=1;i<=b;i++) 05 s=s*a; 06 return s; 07

2 for(i=1;i<=4;i++) s=s*3; 3 81 void gugudan(int k); int dan; printf(" >"); scanf("%d", &dan); gugudan(dan); void gugudan(int k) int i; for(i=1; i<=9; i++) printf("\n%d*%d=%2d", k, i, k*i); int num1, num2; printf(" Enter>"); scanf("%d", &num1); if (num1<0) num2=-num1; printf("\n%d %d", num1, num2); int absolute(int abs) if (abs<0) abs=-abs; return abs;

3 double factorial(int n); int n; printf("\n n!. "); printf("\n n Enter"); scanf("%d", &n); printf("\n n!=%.lf", factorial(n)); double factorial(int k) double product=1; int i; for(i=1; i<=k; i++) product=product*i; return product; int IsLeapYear (int y); int year; printf( : ); scanf( %d, &year); printf( \n %d ); if (IsLeapYear(year)) printf(. ); else printf(. ); int IsLeapYear(int y) if((y%4==0 && y%100!=0) y%400==0) return 1; else

4 01 02 #define square(x) x*x int y=4; 06 printf("%d %d\n",square(y), square(y+1)); square(y+1)=y+1*y int number(int i); number(6); int number(int i) if (i==0) 11 return i; 12 else 13 number(i/2); 14 printf("%d", i%2); 15 number() 2

5 11 X X X X RAM register register

6 int x=0; int x=2; 07 printf("%d", x); 08 x+=3; printf("%d", x); line 10 x line 04 x 0

7 12 stdio.h string.h math.h dos.h scanf() scanf() gets() NULL 1 byte 2 byte fflush() fflush() #include <ctype.h> char ch='a'; printf("%d", isalnum(ch)); printf("%d", isalpha(ch)); printf("%d", isascii(ch)); printf("%d", isdigit(ch)); printf("%d", isupper(ch)); #include <string.h> char *a="visual c++", b[6]="turbo"; printf("%d \n", strlen(a)); printf("%d \n", strcmp(a,b)); printf("%s \n", strlwr(b)); printf("%s \n", strupr(a));

8 01 02 #include <time.h> int i, x, y; 06 srand(time(null)); 07 for(i=1;i<=10;i+=1) x=rand()%9+1; 10 y=rand()%9+1; 11 printf("%d*%d=?\n", x, y); long num= ; char s[25]; ltoa(num2, s, 10); printf( :%d, :%s\n, num, s); 10 printf( :%d\n, strlen(s); ); 11 12

9 01 02 #include <time.h> 03 #include <conio.h> int i; 07 time_t t1. t2; 08 t1 = time(null); 09 printf( : \n%s, ctime(&t1)); t2=t1+3*60l*60l; printf( : \n%s, ctime(&t2)); #include <stdlib.h> 03 #include <time.h> 04 #include <conio.h> int i; 08 time_t t; 09 srand(time(null)); 10 printf(". \n"); 11 printf(".\n"); 12 printf(".\n\n"); 13 printf(" \n"); 14 while(!kbhit()) printf("%2d", rand()%9+1); 18 printf("%2d", rand()%10); 19 printf("%2d", rand()%10); 20 printf("%2d", rand()%10); 21 printf("\n."); 22 23

10 A Z 100 rand() #include <stdlib.h> 03 #include <time.h> int i, rnd; 07 char alpha[26]=0; 08 srand(time(null)); 09 printf(" \n"); 10 for(i=1;i<=100;i++) rnd=rand()%26; 13 printf("%c", rnd+65); 14 if (i%20==0) 15 printf("\n"); 16 alpha[rnd]+=1; printf("\n \n"); 19 for(i=0;i<26;i++) printf("%c : %2d ", i+65, alpha[i]); 22 if ((i+1)%3==0) 23 printf("\n");

11 01 02 #include <math.h> 03 #define PI int i, j ; 07 double sine; 08 for(i=0 ; i<=360 ; i+=15) sine=sin((double)i*pi/180); 11 printf("sin(%3d)= %5.2f", i,sine); 12 for(j=0 ;j<=(int)(sine*10+10);j++) 13 printf(" "); 14 printf("* \n"); #define PI sin((double)i*pi/180); for(j=0; j<=(int)(sine*10+10); j++) printf(" "); sine sine sine '*' sin(0 0 )=0 11 (for(j=0;j<=10;j++) '*' sin(45 0 )= (for(j=0;j<=17;j++) '*'

12 01 #include <time.h> int birthy, birthm, birthd; 06 time_t curr; 07 struct tm *d; 08 curr=time(null); 09 d=localtime(&curr); 10 printf(" Enter.>"); 11 scanf("%d",birthy); 12 printf(" Enter.>"); 13 scanf("%d",birthm); 14 printf(" Enter.>"); 15 scanf("%d",birthd); 16 printf("\n"); 17 printf("%d %d %d \n",d->tm_year+1900,d->tm_mon+1, d->tm_mday); 18 printf(" \n); 19 printf("%d %d %d \n",birthy, birthm, birthd); 20 diffy=birthy-d->tm_year+1900; 21 diffm=birthm-d->tm_mon+1; 22 diffd=birthd-d->tm_mday; 23 if (diffm<=0 && diffd<=0) 24 diffy++; 25 printf(" : %d\n", diffy); 26 27

13 13 int korea[5]; int korea[ ]=2, 4, 9, 6; int korea[3]=2, 4, 9, 6; int korea[5]=2, 8; 0 char c[5]="test"; char c[2]="test"; char c[7]="test"; char c[ ]="test"; auto int num[8]; static int num[8]; register int num[8]; extern int num[8]; 2 3 cha int int arr[7]=11, 22, 33, 44, 55, 66, 77; int i; for(i=1; i<=6; i=i+2) printf("%d\n", arr[i]);

14 i 1 2 arr[1]arr[3]arr[5] 0 < int arr[3]=0; int i; for(i=0; i<3; i++) printf("%d", arr[i]); %c %d %d ASCII char ch[9]="cprogram"; int i; for(i=0; i<8; i++) printf("%c : %3d\n", ch[i], ch[i]); i 2 0 d[2-i] 0 2 double d[3]=0.1, 0.2, 0.3; int i; for(i=2;i>=0;i--) printf("%.1f\n", d[2-i]);

15 korea[9] japan[9] int korea[9]=0,0,0,0,1,0,0,2,0; int japan[9]=1,1,0,0,0,0,0,0,0; int i, sumk=0, sumj=0; printf(" \n\n"); printf(" \t Run\n"); printf("korea\t"); for(i=0;i<9;i++) sumk+=korea[i]; printf("%2d", korea[i]); printf("%3d\n", sumk); printf("japan\t"); for(i=0;i<9;i++) sumj+=japan[i]; printf("%2d", japan[i]); printf("%3d\n", sumj); 6 char num[7];

16 atof() atol() ASCII char num[7]="871209"; 1987 (num[0]-48)*10+num[1] ; '8' ASCII '7' 1 num[1] int birthy, birthm, birthd; char num[7]; printf(">"); scanf("%s", num); birthy=(num[0]-48)*10+num[1] ; birthm=(num[2]-48)*10+num[3]-48; birthd=(num[4]-48)*10+num[5]-48; printf("%d %d %d. \n", birthy, birthm, birthd); t(1,2)=3; t[1,2]=3; t(0)(1)=3; t[0][1]=3; C

17 int a[2][3]=, i, j; for(i=0; i<2;i++) for (j=0;j<3;j++); printf( %d, a[i][j]); printf( \n ); int a[2][2][2]=1,2,3,4,5,6,7,8 3 a a[0][0][0]=1, a[0][0][1]=2 a[0][1][0]=3, a[0][1][1]=4 a[1][0][0]=5, a[1][0][1]=6 a[1][1][0]=7, a[1][1][1]=8 transpose matrix matrix[i][j] matrix[j][i]

18 int matrix[3][3]=2, 4, 6, 8, 10, 12, 14, 16, 18; int i, j; printf("original matrix\n"); for(i=0;i<3;i++) for(j=0;j<3;j++) printf("%2d", matrix[i][j]); printf("\n"); printf("\ntranspose matrix\n"); for(i=0;i<3;i++) for(j=0;j<3;j++) printf("%2d", matrix[j][i]); printf("\n"); long money, i, num; long money_unit[]=10000, 5000, 1000, 500, 100, 50, 10; printf(" Enter>"); scanf("%ld", &money); printf("\n \n"); for(i=0; i<=6;i++) num=money/money_unit[i]; printf("%5ld : %3ld \n", money_unit[i], num); money=money-num*money_unit[i];

19 ASCII 'A' 10 65'a' 97 'A' 'A'-65 0 chr[0] 'a' 'a'-97=0 chr[0] char ch[100]=0; int chr[26]=0, i, nchr=0; printf(" count\n\n"); printf(" Enter\n"); printf(">"); gets(ch); for(i=0; ch[i]!=0 ; i++) if( ch[i]>=65 && 90>= ch[i]) chr[ch[i]-65]+=1; else if (ch[i]>=97 && 122>= ch[i]) chr[ch[i]-97]+=1; else nchr+=1; printf("\n\n"); printf(" count\n"); for(i=0; i<26 ; i++) if (chr[i]==0) continue; printf("%c \t %d\n", i+65, chr[i]); printf("\t %d", nchr);

20 strlen() ASCII #include <string.h> char str[11]; int i, len, sum; printf(" Enter>"); scanf("%s", str); len = strlen(str); sum = 0; for(i = 0; i < len; i++) sum += str[i]; printf(" : %d\n", sum);

21 14 int x; x &x x x x x *po+3 *(po+3) int a[4]=10,20,30,40; int *po=a; 13, 20 13, 40 23, 30 23, 40 13, 23 *po+3 a[0]+3 13*(po+3) a[3] 40 int a[5]=3,1,4,2,5; int *pt=a; *a+1 a[1] *(a+1) *++pt *(pt+1) a a[0] *a+1 a[0]+1 4 *(a+1) a[1] *(pt+1) *++pt ++pt; *pt; a[1] int i=15, j=20, *p; p=&i; j=*p; printf("%d",j); int *p, y[3]=2, 6, 9, a; p=y; a=*p++; printf("%d", a); printf("%d", *p);

22 int i=15, j=20, *p; p=&i; p i j=*p; p 15 j printf("%d",j); a=*p++ a=*p; p++ a=*p; a y[0] p p++ y[1] char *p="computer"; int i=0; while(*p!= '\0') i++; p++; printf("%d",i); char x[3], *p; x[1]='a'; p=&x[1]; *(p-1)='b'; *(p+1)='c'; printf("%c %c %c\n",*(p-1),*p,*(p+1)); char *p="computer"; p "computer" 'c' while p NULL p i while NULL i "computer" 8

23 int k[]=1,2,3,4,*p; p=&k[0]; printf("%d\n",*p); p++; printf("%d\n",*p); printf("%d\n", *p+1); printf("%d\n",*(p+1)); p=&k[0]; p k k[0] p++; p k[1] *p k[1] *p+1 k[1] *(p+1) p &k[1] &k[2] k[2] 3 int a[3][3]=1,2,3,4,5,6,7,8,9; int b[ ][3]=7,8, 9,10,11; printf(" %d \n", a[1][1]); printf(" %d \n",*(a[2]+2)); printf(" %d \n",(*(b+1))[2]); a a[0][0]=1, a[0][1]=2, a[0][2]=3, a[1][0]=4, a[1][1]=5, a[1][2]=6, a[2][0]=7, a[2][1]=8, a[2][2]=9, b b[0][0]=7, b[0][1]=8, b[0][2]=0, b[1][0]=9, b[1][1]=10, b[1][2]=11, *(a[2]+2) a[2] a[2][0] a[2]+1 a[2][1]* a[2]+2 a[2][2] 9 (b+1)

24 b[1][0] (*(b+1))[2] b[1][2] 6 char num[7]; atof() atol() ASCII char num[7]="871209"; 1987 = (num[0]-48)*10+num[1] ; '8' ASCII '7' 1 num[1] int birthy, birthm, birthd, day; char *animal[12]=" ", " ", " ", "", " ", " ", " ", " ", " ", " ", " ", ""; char num[7]; printf(">"); scanf("%s", num); birthy=(num[0]-48)*10+num[1] ; birthm=(num[2]-48)*10+num[3]-48; birthd=(num[4]-48)*10+num[5]-48; printf("%d %d %d, \n", birthy, birthm, birthd);

25 day=(birthy-1900)%12; printf("%s.\n",animal[day]); long long money; long money_unit[]=1000, 500, 100, 50, 10, 5, 1, i, num; char *unit[]=" ", "", " ", "", " ", "", " "; printf(" Enter>"); scanf("%ld", &money); printf("\n\n"); money=money/10l; for(i=0; i<=6; i++) num=money/money_unit[i]; printf("\n%8s %3d", unit[i], num); money=money-num*money_unit[i];

26 int i; long cost[5]=135000, , , , 73500; long quantity[5], sum, total=0; char *good[5]="hard disk", "CPU(intel)", "main board", "LCD monitor", "DVD-RW(combo)"; printf(" \n\n"); printf(" Enter\n"); for(i=0; i<=4; i++) printf("%s: >", good[i]); scanf("%ld", &quantity[i]); printf("\n\n"); printf("\n\t\t\t\t"); for(i=0; i<=4; i++) sum=cost[i]*quantity[i]; printf("\n%s\t%7ld\t%3ld %10ld ", good[i], cost[i], quantity[i], sum); total+=sum; printf("\n \t\t\t %12ld ", total);

27 15 struct user d_1; user PERSON; struct user data[10]; struct user *point; struct user $amount; struct std int number; char *name; ; std st1, st2; struct st1, st2; std struct st1, st2; struct std st1, st2; typedef st1, st2; var name name char name[10]; "kim" name="kim"; *name="kim"; var.name="kim"; strcpy(var.name, "kim"); strcpy() var name name char *name; "kim" name="kim"; *name="kim"; var.name="kim"; strcpy(var.name, "kim");

28 person struct person char name[10]; int age; ; struct person d="park", 18; strcpy(d.name, "Park"); scanf("%s", d.name); d.name="park"; d1 byte struct data char name[12]; long income; double saving; d1; byte 12 byte + 4 byte + 8 byte = 24 byte #include <string.h> struct student char name[20]; int jumsu; ; struct student st; printf(" Enter"); scanf("%s", st.name ); printf(" Enter"); scanf("%d", &st.jumsu ); printf(" : %s \n, st.name ); printf(" : %d \n, st.jumsu ); scanf() &

29 & & struct planet char name[10]; long diameter; float distance; float speed; float cycle; char satellite; bit field bit field bit

30 struct person char name[10]; int age; ; struct person d, *pt; pt=&d; strcpy((*pt).name, "Choi"); strcpy(pt->name, "Choi"); scanf("%s", pt.name); scanf("%s", pt->name); struct person char *name; int age; ; struct person d, *pt; pt=&d; scanf("%s", pt->name); strcpy("%s", pt->name); (*pt).name="lee"; pt->name="lee"; struct human char name01[10]; char *name02; data01="miss Kim", "Mr Park"; struct company char com_name[10]; struct human people; int salary; data02="choi", "Kim", "Park", 500; printf("%s\n", data02.com_name); printf("%s\n", data02.people.name01); printf("%c\n", data01.name01[1]); printf("%d\n ",data02.salary);

31 company data02.com_name "Choi" data02.people.name01 "Kim" data01.name01 "Miss Kim" data01.name01[1] 'i' data02.salary 500

32 16 struct union #include <string.h> 03 union univar char ch1; 06 char ch2[4]; 07 ; union univar data; 11 strcpy(data.ch2, "ABC"); 12 data.ch1='d'; 13 printf("%s\n", data.ch2); DBC data 4 byte (char ch2[4];) strcpy(data.ch2, "ABC"); 1 bit byte 'A' 'B' 'C'

33 data.ch2[0] data.ch2[1] data.ch2[2] A B C NULL data.ch1= D ; data.ch2[10] data.ch1 data.ch2[1] data.ch2[2] D B C NULL DBC enum card spade, diamond, heart, clover; enum card card01; card01=heart; printf("card01 : %d\n", card01); printf("card01 : %d\n", diamond); printf("card01 : %d\n", spade); card01 : 2 card01 : 1 card01 : 0 enum tag_name week card01 enum card spade, diamond, heart, clover; enum card card01; 0 1 space 0 clover 3

34 struct patient char age; unsigned sex : 1; unsigned drinking : 1; unsigned smoking : 1; unsigned marriage : 1; ; struct patient a=24,0,1,1,0; printf("age :%d\n", a.age); printf("sex :%d\n", a.sex); printf("drinking :%d\n", a.drinking); printf("smoking :%d\n", a.smoking); char 1 byte 1 bit 4 bit 1 byte + 4 bit byte a 2 byte sex 01 drinking 1smoking 1 marriage 1 24 struct patient char age; unsigned sex : 1; unsigned drinking : 1; unsigned smoking : 1; unsigned marriage : 1; ; struct patient a=24,0,1,1,0; printf(" :%d\n", a.age); if (a.sex==0) printf(" : \n"); else printf(" : \n");

35 if (a.drinking==0) printf(" : \n"); else printf(" : \n"); if (a.smoking==0) printf(" : \n"); else printf(" : \n"); if (a.marriage==0) printf(" : \n"); else printf(" : \n");

36 17 ASCII byte type stream open fopen() open open fgets(), fputs() X 's' string fprintf printf fscanf() X fscanf() scanf() fgets() fread() FILE X C high level I/O low level I/O

37 CD X NULL X fopen() NULL NULL exit() r w a fgets() fscanf() fgetc() fputs()

38 #include <stdlib.h> char *name[3]=" "," ", " "; char *phone[3]=" ", " ", " "; int i; FILE *fp; fp=fopen("sample", "w"); if (fp==null) printf("file open "); exit(1); for(i=0;i<3;i++) printf("%s %s\n", name[i], phone[i]); fprintf(fp, "%s %d\n", name[i], phone[i]); fclose(fp); #include <stdlib.h> char c; FILE *fp; fp=fopen( chr.txt, r ) if (fp==null) printf( File open ) exit(1); while((c=fgetc(fp))!= EOF ) printf( %c, c ) fclose(fp); printf( \n );

39 int i; long cost[5]=135000, , , , 73500; long quantity[5], sum, total=0; char *good[5]="hard disk", "CPU(intel)", "main board", "LCD monitor", "DVD-RW(combo)"; FILE *fp; printf(" \n\n"); printf(" Enter\n"); for(i=0; i<=4; i++) printf("%s: >", good[i]); scanf("%ld", &quantity[i]); fp=fopen("sale.txt", "w"); printf("\n\n"); fprintf(fp, "\n\n"); printf("\n\t\t\t\t"); fprintf(fp, "\n\t\t\t\t\n"); for(i=0; i<=4; i++) sum=cost[i]*quantity[i]; printf("\n%s\t%7ld\t%3ld %10ld ", good[i], cost[i], quantity[i], sum); fprintf(fp, "%s\t%7ld\t%3ld %10ld \n", good[i], cost[i], quantity[i], sum); total+=sum; printf("\n \t\t\t %12ld ", total); fprintf(fp, "\n \t\t\t %12ld ", total); fclose(fp);

40 wb ASCII ASCII byte type random access block block block block block block block fread()block fread() block fseek() fp=fopen("group.dat", "rb"); fseek(fp, 0L, SEEK_END); total_block= ftell(fp) / sizeof(stdata) ; ftell() byte byte block byte blockbyte SEEK_END offset 0 byte ftell() block fseek(fp, 0L, SEEK_END); total=ftell(fp)/sizeof(stdata); block block

41 10 byte 10 byte 10 byte 10 byte block block block block whence block (n=1) block (SEEK_SET) (SEEK_END) offset fseek(fp, -30L, SEEK_END); 10 byte 10 byte 10 byte block block block block fseek(fp, 20L, SEEK_SET); 10 byte block block block block #include <stdlib.h> struct sale char good[15]; long cost; long quantity; long total;

42 ; int i; long total=0; struct sale sdata[5]="hard disk", , "CPU(intel)", , "main board", , "LCD monitor",260000, "DVD-RW(combo)",73500; FILE *fp; printf(" \n\n"); printf(" Enter\n"); for(i=0; i<=4; i++) printf("%s: >", sdata[i].good); scanf("%ld", &sdata[i].quantity); fp=fopen("sale.bin", "wb"); printf("\n\n"); printf("\n\t\t\t\t"); for(i=0; i<=4; i++) sdata[i].total=sdata[i].cost*sdata[i].quantity; printf("\n%s\t%7ld\t%3ld %10ld ", sdata[i].good, sdata[i].cost, sdata[i].quantity, sdata[i].total); total+=sdata[i].total; printf("\n \t\t\t %12ld ", total); if(fwrite(sdata, sizeof(sale), 5, fp)!=5) printf("file Write Error!"); exit(1); fclose(fp);

43 #include <stdlib.h> struct sale char good[15]; long cost; long quantity; long total; ; int i; long total_block, block_number; struct sale d; FILE *fp; fp=fopen("sale.bin", "rb"); fseek(fp, 0L, SEEK_END); total_block=ftell(fp)/sizeof(sale); printf(" \n\n"); printf(" block %d.\n", total_block); printf("0 \n", total_block); while(1) printf("\n block (1-%d) Enter >", total_block); scanf("%ld", &block_number); if (block_number==0) break; fflush(stdin); if (block_number> total_block) break; fseek(fp, sizeof(sale)*(block_number-1), SEEK_SET); if(fread(&d, sizeof(sale), 1, fp)!=1) printf("file read Error!");

44 exit(1); printf("\n\t\t\t\t\n"); printf("%s\t%7ld\t%3ld %10ld \n", d.good, d.cost, d.quantity, d.total); fclose(fp);

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 #define _CRT_SECURE_NO_WARNINGS #include #include main() { char ch; printf(" 문자 1개를입력하시오 : "); scanf("%c", &ch); if (isalpha(ch))

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

untitled

untitled while do-while for break continue while( ) ; #include 0 i int main(void) int meter; int i = 0; while(i < 3) meter = i * 1609; printf("%d %d \n", i, meter); i++; return 0; i i< 3 () 0 (1)

More information

untitled

untitled if( ) ; if( sales > 2000 ) bonus = 200; if( score >= 60 ) printf(".\n"); if( height >= 130 && age >= 10 ) printf(".\n"); if ( temperature < 0 ) printf(".\n"); // printf(" %.\n \n", temperature); // if(

More information

http://cafedaumnet/pway Chapter 1 Chapter 2 21 printf("this is my first program\n"); printf("\n"); printf("-------------------------\n"); printf("this is my second program\n"); printf("-------------------------\n");

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

61 62 63 64 234 235 p r i n t f ( % 5 d :, i+1); g e t s ( s t u d e n t _ n a m e [ i ] ) ; if (student_name[i][0] == \ 0 ) i = MAX; p r i n t f (\ n :\ n ); 6 1 for (i = 0; student_name[i][0]!= \ 0&&

More information

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어 개나리 연구소 C 언어 노트 (tyback.egloos.com) 프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어먹고 하더라구요. 그래서,

More information

untitled

untitled int i = 10; char c = 69; float f = 12.3; int i = 10; char c = 69; float f = 12.3; printf("i : %u\n", &i); // i printf("c : %u\n", &c); // c printf("f : %u\n", &f); // f return 0; i : 1245024 c : 1245015

More information

chap8.PDF

chap8.PDF 8 Hello!! C 2 3 4 struct - {...... }; struct jum{ int x_axis; int y_axis; }; struct - {...... } - ; struct jum{ int x_axis; int y_axis; }point1, *point2; 5 struct {....... } - ; struct{ int x_axis; int

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 24. 파일입출력 2013.11.27. 오병우 컴퓨터공학과 파일 (File) 입출력 표준입출력 vs. 파일입출력 HDD 프로그래머입장에서는동일한방법으로입출력 다만 file 을읽고쓰기전에 Open 해서스트림에대한파일포인터 (file pointer) 를얻어야한다. OS 가실제작업을대행하며, 프로그래머는적절한함수를적절한방법으로호출 Department

More information

untitled

untitled 자료형 기본자료형 : char, int, float, double 등 파생자료형 : 배열, 열거형, 구조체, 공용체 vs struct 구조체 _ 태그 _ 이름 자료형멤버 _ 이름 ; 자료형멤버 _ 이름 ;... ; struct student int number; // char name[10]; // double height; // ; // x값과 y값으로이루어지는화면의좌표

More information

Microsoft PowerPoint - 제11강 파일 처리

Microsoft PowerPoint - 제11강 파일 처리 제13장 파일 처리 파일열기 : File Open FILE *fp; fp=fopen( filename, r ); File handling mode: r, w, a, rb, wb, ab, r+, w+, a+ fclose(fp) 파일의종류 : Text File, Binary File Text file:.txt,.doc,.hwp Binary file:.exe,.jpg,.gif,.mov,.mpeg,.tif,.pgm,.ppm.

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

More information

歯7장.PDF

歯7장.PDF 7 Hello!! C 2 . 3 ([] ) < > [ ]; int array[10]; < > [ ][ ]; int array [3] [5]; 4 < > [ ]={ x1,,x10} ( ); (,). ({}). : int array[10]={1,2,3,4,5,6,7,8,9,10}; (" "). : char array[7]="turbo-c"; 5 int array[2][3]={{1,2},{3,4},{5,6}};

More information

chap7.PDF

chap7.PDF 7 Hello!! C 2 . 3 ([] ) < > [ ]; int array[10]; < > [ ][ ]; int array [3] [5]; 4 < > [ ]={ x1,,x10} ( ); (,). ({}). : int array[10]={1,2,3,4,5,6,7,8,9,10}; (" "). : char array[7]="turbo-c"; 5 int array[2][3]={{1,2},{3,4},{5,6}};

More information

13 주차문자열의표현과입출력

13 주차문자열의표현과입출력 13 주차문자열의표현과입출력 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 C 언어를이용하여문자열을처리하기위해서는문자형의배열이나포인터를사용하게된다. 문자열을처리하는동작으로는단순하게문자열의입력이나출력기능이외에도문자열의복사나치환, 문자열의길이를구하거나문자열을비교하는기능등많은기능을필요로한다. 그러나이러한기능들을모두구현하기란매우까다로우며,

More information

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4 Introduction to software design 2012-1 Final 2012.06.13 16:00-18:00 Student ID: Name: - 1 - 0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x

More information

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

int main(void) int a; int b; a=3; b=a+5; printf(a : %d \n, a); printf(b : %d \n, b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf( a : %x \ ? 1 int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \n", &a); printf(" b : %x \n", &b); * : 12ff60,

More information

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 종합과제 과제내용 구조체를이용하여교과목이름과코드를파일로부터입력받아관리 구조체를이용하여학생들의이름, 학번과이수한교과목의코드와점수를파일로부터입력 학생개인별총점, 평균계산 교과목별이수학생수, 총점및평균을계산 결과를파일에저장하는프로그램을작성 2 Makefile OBJS = score_main.o score_input.o score_calc.o score_print.o

More information

Microsoft PowerPoint - chap4 [호환 모드]

Microsoft PowerPoint - chap4 [호환 모드] 제 5 장 C 표준라이브러리 숙대창병모 1 목표 C 표준라이브러리의깊이있는이해 시스템호출과 C 표준라이브러리관계 숙대창병모 2 C 입출력라이브러리함수 숙대창병모 3 시스템호출과라이브러리함수 System Calls well defined entry points directly into the kernel documented in section 2 of the

More information

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2>

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2> 문자열처리라이브러리 함수 설명 strlen(s) 문자열 s의길이를구한다. strcpy(s1, s2) s2를 s1에복사한다. strcat(s1, s2) s2를 s1의끝에붙여넣는다. strcmp(s1, s2) s1과 s2를비교한다. strncpy(s1, s2, n) s2의최대n개의문자를 s1에복사한다. strncat(s1, s2, n) s2의최대n개의문자를 s1의끝에붙여넣는다.

More information

Microsoft PowerPoint - Chapter_07.pptx

Microsoft PowerPoint - Chapter_07.pptx 프로그래밍 1 1 Chapter 7. Arrays May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 배열의정의를이해한다. 배열의선언방법을이해한다. 각배열원소를접근하는방법을이해한다. 문자열의특징을이해한다. 문자열관련라이브러리의사용방법을이해한다.

More information

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7> 제14장 동적 메모리 할당 Dynamic Allocation void * malloc(sizeof(char)*256) void * calloc(sizeof(char), 256) void * realloc(void *, size_t); Self-Referece NODE struct selfref { int n; struct selfref *next; }; Linked

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

Microsoft PowerPoint - Chapter_09.pptx

Microsoft PowerPoint - Chapter_09.pptx 프로그래밍 1 1 Chapter 9. Structures May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 구조체의개념 (1/4) 2 (0,0) 구조체 : 다양한종류의데이터로구성된사용자정의데이터타입 복잡한자료를다루는것을편하게해줌 예 #1: 정수로이루어진 x,

More information

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054>

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054> 의료프로그래밍실습 의료공학과이기영 1 Chap. 11 파일입출력 2 1 이장의목표 텍스트파일의입출력방법을익힌다. (284 쪽그림참조 ) 3 C 언어의파일종류 텍스트파일 (text file) 사람들이읽을수있는문자들을저장하고있는파일 텍스트파일에서 한줄의끝 을나타내는표현은파일이읽어들여질때, C 내부의방식으로변환된다. 이진파일 (binary file) : 자료형그대로의바이트수로연속해서저장

More information

Microsoft PowerPoint - chap11-포인터의활용.pptx

Microsoft PowerPoint - chap11-포인터의활용.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 포인터를 사용하는 다양한 방법에

More information

Microsoft PowerPoint - Lesson13.pptx

Microsoft PowerPoint - Lesson13.pptx 2008 Spring Computer Engineering g Programming g 1 Lesson 13 - 제 16 장파일입출력 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 파일의기초 텍스트파일읽기와쓰기 이진파일읽기와쓰기 임의접근파일 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

C 언어 프로그래밊 과제 풀이

C 언어 프로그래밊 과제 풀이 과제풀이 (1) 홀수 / 짝수판정 (1) /* 20094123 홍길동 20100324 */ /* even_or_odd.c */ /* 정수를입력받아홀수인지짝수인지판정하는프로그램 */ int number; printf(" 정수를입력하시오 => "); scanf("%d", &number); 확인 주석문 가필요한이유 printf 와 scanf 쌍

More information

11장 포인터

11장 포인터 쉽게풀어쓴 C 언어 Express 제 12 장문자와문자열 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것이다. 문자의중요성 인간한테텍스트는대단히중요하다.

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

Computer Programming (2008 Fall)

Computer Programming  (2008 Fall) Computer Programming Practice (2011 Winter) Practice 12 Standard C Libraries The Last Practice 2012. 01. 25 2/24 Contents Standard C Libraries Input & Output Functions : stdio.h String Functions : string.h

More information

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

Microsoft PowerPoint - 10장 문자열 pptx

Microsoft PowerPoint - 10장 문자열 pptx C 프로그래밍및실습 10. 문자열 세종대학교 목차 1) 문자열이란? 2) 문자열과포인터 3) 문자열의배열 4) 문자열처리함수 5) 문자열및문자입출력 2 1) 문자열이란 문자배열 ( 복습 ) 원소가문자인배열 각배열원소를하나의단위로처리 : 초기화, 입출력 char str[8] = {'H','e','l','l','o'}; // 문자로초기화 int i; for (i=0

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

C Programming

C Programming C Programming 파일입출력 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 파일입출력 파일입출력함수 파일처리함수 2 파일입출력 파일입출력 파일의이해 파일입출력의이해 파일입출력함수 파일처리함수 3 파일의이해 파일 (File) 하나의단위로취급해야하는데이터들의외부적컬렉션 파일의종류 텍스트파일 :

More information

106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float

106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float Part 2 31 32 33 106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float f[size]; /* 10 /* c 10 /* f 20 3 1

More information

; struct point p[10] = {{1, 2, {5, -3, {-3, 5, {-6, -2, {2, 2, {-3, -3, {-9, 2, {7, 8, {-6, 4, {8, -5; for (i = 0; i < 10; i++){ if (p[i].x > 0 && p[i

; struct point p[10] = {{1, 2, {5, -3, {-3, 5, {-6, -2, {2, 2, {-3, -3, {-9, 2, {7, 8, {-6, 4, {8, -5; for (i = 0; i < 10; i++){ if (p[i].x > 0 && p[i ; struct point p; printf("0이아닌점의좌표를입력하시오 : "); scanf("%d %d", &p.x, &p.y); if (p.x > 0 && p.y > 0) printf("1사분면에있다.\n"); if (p.x < 0 && p.y > 0) printf("2사분면에있다.\n"); if (p.x < 0 && p.y < 0) printf("3사분면에있다.\n");

More information

Microsoft PowerPoint - chap-12.pptx

Microsoft PowerPoint - chap-12.pptx 쉽게풀어쓴 C 언어 Express 제 12 장문자와문자열 컴퓨터프로그래밍기초 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것이다. 컴퓨터프로그래밍기초 2

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것입니다. 2

이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다. 이번장에서는 C 에서의문자열처리방법에대하여자세히살펴볼것입니다. 2 제 12 장문자와문자열 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 인간은문자를사용하여정보를표현하므로문자열은프로그램에서중요한위치를차지하고있다.

More information

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

More information

Microsoft PowerPoint - 10_C_Language_Text_Files

Microsoft PowerPoint - 10_C_Language_Text_Files C Language 파일입출력 Doo-ok Seo clickseo@gmail.com http:// 목 차 파일입출력개념 파일입출력함수 기타파일처리함수 2 파일입출력개념 파일입출력개념 파일의기본개념 파일시스템의개요 FILE 구조체 파일테이블 파일열기및닫기 : fopen, fclose 함수 파일입출력함수 기타파일처리함수 3 파일의기본개념 파일입출력개념 하나의단위로취급해야하는데이터들의외부적컬렉션이다.

More information

Microsoft PowerPoint - 09_(C_Programming)_(Korean)_File_Processing

Microsoft PowerPoint - 09_(C_Programming)_(Korean)_File_Processing C Programming 파일처리 (File Processing) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 파일입출력 텍스트파일입출력함수 이진파일입출력함수 다양한파일처리함수 2 파일입출력 파일입출력 입출력스트림 파일과파일입출력 텍스트파일입출력함수 이진파일입출력함수 다양한파일처리함수 3 스트림 (Stream) 데이터의논리적흐름

More information

C 프로그래밊 개요

C 프로그래밊 개요 함수 (2) 2009 년 9 월 24 일 김경중 공지사항 10 월 1 일목요일수업휴강 숙제 #1 마감 : 10 월 6 일화요일 기초 함수를만들어라! 입력 함수 ( 기능수행 ) 반환 사용자정의함수 정의 : 사용자가자신의목적에따라직접작성한함수 함수의원형 (Function Prototype) + 함수의본체 (Function Body) : 함수의원형은함수에대한기본적정보만을포함

More information

ABC 11장

ABC 11장 12 장입력과출력 getchar()/putchar() printf()/scanf() sprintf()/sscanf() 파일입출력 fprintf()/fscanf() 파일의임의의위치접근 내용 ftell(), fseek(), rewind() 텍스트파일 이진파일 fread()/fwrite() 1 getchar()/putchar() 함수원형 int getchar(void);

More information

C 프로그래밊 개요

C 프로그래밊 개요 구조체 2009 년 5 월 19 일 김경중 강의계획수정 일자계획 Quiz 실습보강 5 월 19 일 ( 화 ) 구조체 Quiz ( 함수 ) 5 월 21 일 ( 목 ) 구조체저녁 6 시 5 월 26 일 ( 화 ) 포인터 5 월 28 일 ( 목 ) 특강 (12:00-1:30) 6 월 2 일 ( 화 ) 포인터 Quiz ( 구조체 ) 저녁 6 시 6 월 4 일 ( 목

More information

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2 제 17 장동적메모리와연결리스트 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

중간고사

중간고사 중간고사 예제 1 사용자로부터받은두개의숫자 x, y 중에서큰수를찾는알고리즘을의사코드로작성하시오. Step 1: Input x, y Step 2: if (x > y) then MAX

More information

Microsoft PowerPoint - 7_배열_문자열

Microsoft PowerPoint - 7_배열_문자열 * 이번주주제: 배열, 문자열 1 * 지난주내용: 함수 2 * 배열의 개념 (p86) - 복수의 동일한 데이터 형의 변수를 하나로 묶은 것. - 대량의 데이터를 취급할 때나 여러 데이터를 차례로 자동적으로 입출력해야 할 때 배열을 사용 하면 편리. - 배열도 변수와 마찬가지로 선언이 필요. - 배열을 초기화 할 때는 { }를 사용하여 값을 열거. - [ ]안의

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

untitled

untitled 1 hamks@dongguk.ac.kr (goal) (abstraction), (modularity), (interface) (efficient) (robust) C Unix C Unix (operating system) (network) (compiler) (machine architecture) 1 2 3 4 5 6 7 8 9 10 ANSI C Systems

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

Microsoft PowerPoint - Chap14_FileAccess.pptx

Microsoft PowerPoint - Chap14_FileAccess.pptx C 프로그래밍및실습 14. 파일입출력 세종대학교 목차 1) 파일입출력개요 2) 파일입출력절차 3) 텍스트파일 vs. 이진파일 4) 텍스트파일의입출력함수 5) 이진파일의입출력함수 ( 심화내용 ) 6) 기타파일입출력관련함수 ( 심화내용 ) 2 표준입출력 1) 파일입출력개요 표준입력장치 ( 키보드 ) 를통해입력받아처리하여표준출력장치 ( 모니터 ) 를통해결과를보여주는것

More information

1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문

1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문 1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문 1. 표준입출력 표준입출력 입력 : 키보드, scanf 함수 출력 : 모니터, printf 함수문제 : 정수값 2개를입력받고두값사이의값들을더하여출력하라. #include int main(void) int Num1, Num2; int

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

商用

商用 商用 %{ /* * line numbering 1 */ int lineno = 1 % \n { lineno++ ECHO ^.*$ printf("%d\t%s", lineno, yytext) $ lex ln1.l $ gcc -o ln1 lex.yy.c -ll day := (1461*y) div 4 + (153*m+2) div 5 + d if a then c :=

More information

C프로-3장c03逞풚

C프로-3장c03逞풚 C h a p t e r 03 C++ 3 1 9 4 3 break continue 2 110 if if else if else switch 1 if if if 3 1 1 if 2 2 3 if if 1 2 111 01 #include 02 using namespace std; 03 void main( ) 04 { 05 int x; 06 07

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information

윤성우의 열혈 TCP/IP 소켓 프로그래밍

윤성우의 열혈 TCP/IP 소켓 프로그래밍 C 프로그래밍프로젝트 Chap 22. 구조체와사용자정의자료형 1 2013.10.10. 오병우 컴퓨터공학과 구조체의정의 (Structure) 구조체 하나이상의기본자료형을기반으로사용자정의자료형 (User Defined Data Type) 을만들수있는문법요소 배열 vs. 구조체 배열 : 한가지자료형의집합 구조체 : 여러가지자료형의집합 사용자정의자료형 struct

More information

Chapter_06

Chapter_06 프로그래밍 1 1 Chapter 6. Functions and Program Structure April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 문자의입력방법을이해한다. 중첩된 if문을이해한다. while 반복문의사용법을익힌다. do 반복문의사용법을익힌다.

More information

Microsoft PowerPoint - Chapter_05.pptx

Microsoft PowerPoint - Chapter_05.pptx 프로그래밍 1 1 Chapter 5. Functions and Control Flow April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 printf 함수와 scanf 함수의이해함수의이해대표적제어문인 if와 for 문을이해한다. 코드블록

More information

T100MD+

T100MD+ User s Manual 100% ) ( x b a a + 1 RX+ TX+ DTR GND TX+ RX+ DTR GND RX+ TX+ DTR GND DSR RX+ TX+ DTR GND DSR [ DCE TYPE ] [ DCE TYPE ] RS232 Format Baud 1 T100MD+

More information

문서의 제목 나눔명조R, 40pt

문서의 제목  나눔명조R, 40pt 이문서는나눔글꼴로작성되었습니다. 설치하기 11차시 : 함수동적메모리할당다차원배열 프로그래밍및실험 제 11주 동국대학교조영석 6.6 함수인자로써의배열 - 함수정의에서배열로선언된형식매개변수는 pointer임. - 함수의인자로배열이전달되면배열의기본주소가 ( 배열의내용이아님 ) call-by-value로전달됨. - 배열원소는복사되지않음. 2 ( 예 ) #include

More information

Microsoft PowerPoint - chap03-변수와데이터형.pptx

Microsoft PowerPoint - chap03-변수와데이터형.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num %d\n", num); return 0; } 1 학습목표 의 개념에 대해 알아본다.

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined data types) : 다양한자료형을묶어서목적에따라새로운자료형을

구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined data types) : 다양한자료형을묶어서목적에따라새로운자료형을 (structures) 구조체정의 구조체선언및초기화 구조체배열 구조체포인터 구조체배열과포인터 구조체와함수 중첩된구조체 구조체동적할당 공용체 (union) 1 구조체정의 자료형 (data types) 기본자료형 (primitive data types) : char, int, float 등과같이 C 언어에서제공하는자료형. 사용자정의자료형 (user-defined

More information

Microsoft PowerPoint - Chapter8.pptx

Microsoft PowerPoint - Chapter8.pptx Computer Engineering g Programming g 2 제 8 장함수 Lecturer: JUNBEOM YOO jbyoo@konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 모듈화 함수의개념, 역할 함수작성방법 반환값 인수전달 규모가큰프로그램은전체문제를보다단순하고이해하기쉬운함수로나누어서프로그램을작성하여야합니다.

More information

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

More information

02장.배열과 클래스

02장.배열과 클래스 ---------------- DATA STRUCTURES USING C ---------------- CHAPTER 배열과구조체 1/20 많은자료의처리? 배열 (array), 구조체 (struct) 성적처리프로그램에서 45 명의성적을저장하는방법 주소록프로그램에서친구들의다양한정보 ( 이름, 전화번호, 주소, 이메일등 ) 를통합하여저장하는방법 홍길동 이름 :

More information

기초컴퓨터프로그래밍

기초컴퓨터프로그래밍 구조체 #include int main() { } printf("structure\n"); printf("instructor: Keon Myung Lee\n"); return 0; 내용 구조체 (struct) Typedef 공용체 (union) 열거형 (enum) 구조체 구조체 (structure) 어떤대상을표현하는서로연관된항목 ( 변수 )

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 12 표준입출력과파일입출력... 1. 표준입출력함수 2. 파일입출력함수 1. 표준입출력함수 표준입출력함수 표준입력 (stdin, Standard Input) : 키보드입력 표준출력 (stdout, StandardOutput) : 모니터출력 1. 표준입출력함수 서식화된입출력함수 printf(), scanf() 서식의위치에올수있는것들 [ 기본 11-1]

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 4 (Object) (Class) (Instance) (Method) (Constructor) Memory 1 UML 1 @ & 1 (Real World) (Software World) @ &.. () () @ & 2 (Real World) (Software World) OOA/ Modeling Abstraction Instantiation

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

컴파일러

컴파일러 YACC 응용예 Desktop Calculator 7/23 Lex 입력 수식문법을위한 lex 입력 : calc.l %{ #include calc.tab.h" %} %% [0-9]+ return(number) [ \t] \n return(0) \+ return('+') \* return('*'). { printf("'%c': illegal character\n",

More information

Microsoft PowerPoint - ch08 - 구조체 (structure) am0845

Microsoft PowerPoint - ch08 - 구조체 (structure) am0845 2015-1 프로그래밍언어 8. 구조체 (Structure) 2015 년 4 월 11 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 구조체란무엇인가? 구조체의선언, 초기화, 사용

More information

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2>

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2> 2015-1 5. 문자열 (string), 파일입출력 March 9, 2015 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, College of Engineering, Yeungnam University, KOREA (Tel : +82-53-810-2497; Fax

More information

C Language Programming_문제.hwp

C Language Programming_문제.hwp Chapter 1. C 프로그래밍시작 1. 예제 Ⅰ. 예제 _1.1 - 주석사용연습예제 /* */ 여기는주석부분입니다. 컴파일시이부분은컴파일되지않는 코드영역입니다. // 이것또한주석입니다. printf("hello World!\n"); Ⅱ. 예제 _1.2 - 특수문자사용연습예제 printf("\t#### 성적표 ####\n"); printf("=============================================\n");

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 파일입출력 Heeseung Jo 이장의내용 파일과파일포인터 파일입출력함수 임의접근파일처리 2 파일과파일포인터 파일 파일은모든데이터를연속된바이트형태로저장 4 C 언어의파일종류 텍스트파일 (text file) 사람들이읽을수있는문자들을저장하고있는파일 텍스트파일에서 " 한줄의끝 " 을나타내는표현은파일이읽어들여질때, C 내부의방식으로변환 예, a.txt, main.c,

More information

14 주차구조체와공용체

14 주차구조체와공용체 14 주차구조체와공용체 구조체의개념, 정의, 초기화방법 구조체와포인터와의관계 공용체와 typedef 자료형구조 자료형 (data type) 기초자료형 파생자료형 사용자정의자료형 char int float double void 배열포인터구조체공용체 typedef enum 구조체의용도 복잡한형태의데이터란한가지형태의자료가아닌복합형의자료로구성되어있어기본자료형이나배열로는표현하기힘든형태의데이터를말한다.

More information

Microsoft PowerPoint - chap11-1.ppt [호환 모드]

Microsoft PowerPoint - chap11-1.ppt [호환 모드] chapter 11-1 참고자료. 파일입출력 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr k 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- ehanbit.net 파일입출력의개념 파일은데이터를입출력하는모든대상을의미한다. - 키보드로부터데이터를입력하고모니터로출력하는것은키보드파일과 모니터파일로데이터를입출력하는것이다.

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 10 장문자와문자열 이번장에서학습할내용 문자표현방법 문자열표현방법 문자열이란무엇인가? 문자열의입출력 문자처리라이브러리함수 표준입출력라이브러리함수 문자와문자열처리방법에대하여살펴볼것이다. 문자표현방법 컴퓨터에서는각각의문자에숫자코드를붙여서표시한다. 아스키코드 (ASCII code): 표준적인 8비트문자코드 0에서 127까지의숫자를이용하여문자표현

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 10 포인터 01 포인터의기본 02 인자전달방법 03 포인터와배열 04 포인터와문자열 변수의주소를저장하는포인터에대해알아본다. 함수의인자를값과주소로전달하는방법을알아본다. 포인터와배열의관계를알아본다. 포인터와문자열의관계를알아본다. 1.1 포인터선언 포인터선언방법 자료형 * 변수명 ; int * ptr; * 연산자가하나이면 1 차원포인터 1 차원포인터는일반변수의주소를값으로가짐

More information