[[프로그래밍_NOTE]] 124

9/9 필기

※ 임베디드 개론 김종화 ◆ What are embedded System? - 제한된 자원의 hardware & software가 조합되어 특정한 목적을 수행하기 위한 시스템 (ex : 비행기 , 냉장고 , 세탁기 등등) ◆ 판매가↓ 생산원가↓ → 이윤↑ ◆ 로봇 청소기 버튼 -> '벽'을 인식 ※복잡하고 새로운 알고리즘이 아니라 기존의 아이디어에 새로운발상을 더해 새로운 시스템을 창조한다. ◆ Microprocessor XBox360 .vs. playStation3 -------------------------------------------------------- 복수개의 동일 CPU main cpu 및 Cell chip 범용성 특수성 성능↑ but 개발이 어렵..

function , macro , recursive [01.07.24]

function [함수] : 일반적으로 프로그래밍 언어는 주 프로그램 외에 서브루틴 또는 프로시져(procedure)와 함수(function)로 구성된다. 서브루틴 또는 프로시져는 주 프로그램에서 호출(call)되어 특정작업을 수행한 후 주 프로그램으로 복귀(return)한다. 함수도 위와 똑같지만 , 수행결과로서 반환되는 값(return value)을 주 프로그램에 넘긴다는 차이가 있다. macro [매크로] : 매크로 정의는 함수와 같은 인수를 포함하는 문자열을 정의한다. 사용되는 위치에 인수를 포함하는 해당 문자열을 삽입하며, 함수와는 달리 호출과 복귀에 따른 오버헤드가 없다. 따라서 여러가지 주의해야 할 점을 가지고 있다. recursive [재귀] : 재귀(recursive)라는 것은 함수가 직..

문자열 계산기 일부 GetToken() 함수 구현

////////////////////////////////////// Written by SeungHwan 2008.08.20 File of GetToken() 기능 : 문자열로 입력된 수식을 구분 ////////////////////////////////////// #include int GetToken(char* temp , char* buffer) { static int i_T_Count=0; static int i_B_Count=0; while(temp[i_T_Count]) { while(temp[i_T_Count] ==' ') { i_T_Count++; } for(i_B_Count=0 ; temp[i_T_Count] !=' ' && temp[i_T_Count]!=NULL ; i_B_Count++..

shollow copy , deep copy

// 얕은 복사 문제 ////////////////// // shollow copy error ////////////// #include #include #include void main() { char *Name1; char *Name2; char temp[1024]; printf("이름1 : "); gets(temp); Name1 = (char*)malloc(strlen(temp)+1); strcpy(Name1 , temp); Name2 = Name1; printf("=================\n"); printf("이름1 : %s\n", Name1); printf("이름2 : %s\n", Name2); free(Name1); free(Name2); } // 깊은 복사 //////////////..

gets() 안전한 사용법

// 문제가 될수 있는 소스 ////////////////////// #include void main() { char Name[5]; char Addr[5]; char TelNo[5]; printf("이름 : "); gets(Name); printf("주소 : "); gets(Addr); printf("전화 : "); gets(TelNo); printf("이름 : %s\n", Name); printf("주소 : %s\n", Addr); printf("전화 : %s\n", TelNo); } // 결과 화면 ////////////////////////////// ※ gets() 는 버퍼 오버플로우 검사를 하지 않기때문에 사용자가 배열의 크기를 알고 있지 못하다면, 다른 배열의 영역을 침범하기 쉽다. // ..

함수 포인터 연습

// [[ 1 ]] /////////////////////////////////////////// // 사용자 입력에 따라 선택적으로 함수를 호출할 수 있다. //////////////////////////////////////////////////// #include void foo() { printf("foo\n"); } void goo() { printf("goo\n"); } void main() { void (*p[2])() = {foo,goo}; int iChoice; scanf("%d",&iChoice);fflush(stdin); switch(iChoice) { case 0: p[0](); break; case 1: p[1](); break; } } // [[ 2 ]] /////////////..