KLDP 에서 자료를 검색하던 중 GDB와 관련된 매우 유용한 글타래를 발견하고 여기에 링크를 걸어둔다.
Category Archives: C_C++
HPUX 컴파일러 aCC 옵션
HPUX 를 사용하게되면 필연적으로 aCC와 친해져야 하는데, 보통의 gcc, g++과는 옵션 및 사용방법이 틀려 고생하는 경우가 있다.
아래의 링크에 aCC 매뉴얼을 링크해 두었다.
ios::nocreate
C++ 프로그래밍을 공부하던 중, 예제 프로그램을 컴파일하다 다음과 같은 에러를 발견했다.
Description Resource Path Location Type
‘nocreat’ is not a member of ‘std::ios’ Config.cpp /TEMS/src line 40 C/C++ Problem
환경은 이클립스 3.5.2 버전이었으며, g++ 버전은 version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 이었다.
문제의 원인을 찾기 위해 구글링을 해보니 답은 간단했다.
더이상 ios::nocreate 는 표준 C++ 에서 지원하지 않는다는 것.
http://cboard.cprogramming.com/cplusplus-programming/48548-if-ofstream.html 에서 다음과 같은 답변을 찾았다.
ios::nocreate was removed from standard c++, you may use ios::in to open
the file for reading, and not create one if it doesn’t exist.
The file shouldn’t be created if you have a standard compliant compiler.
(I think dc++ is)
ios::nocreate 를 쓰고 싶다면 그냥 ios::in 만 사용하면 된다. 🙂
함수 이름을 포인터에 할당하여 사용하기
// funcPtr.c
//
// Copyright 2009 Kim Sung-tae <pchero@MyNote>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.#include <stdio.h>
#define FUNC1 func1
#define FUNC2 func2int func1(int intVal1) { return –intVal1; }
int func2(int intVal2) { return –intVal2; }int runFunc(char* string, int inVal)
{
int retVal;
int (*funcPtr)(int retVal);
funcPtr = string;
return (*funcPtr)(inVal);
}int main(int argc, char** argv)
{
int intVal = 3;
intVal = runFunc(FUNC2, intVal);
printf(“After running func2 intVal : %dn”, intVal);
intVal = runFunc(FUNC1, intVal);
printf(“After running func1 intVal : %dn”, intVal);
return 0;
}
함수 이름을 포인터에 할당하여 사용하는 재미있는 프로그램.
함수들을 필요한 순서대로 만들어 둔 뒤, 포인터를 이용하여 상황에 따라 적절한 함수가 호출되도록 만든다면 상태머신(State machine)프로그램 등 유용하게 사용할 수 있을 것이다.
printf scanf 특수문자 도표
* ESC 문자열과 의미
|
ESC 문자열 |
ASCII CODE |
의 미 |
|
n |
10 |
new line : 새로운 줄의 시작 |
|
t |
9 |
tab : 커서 또는 프린터 헤드를 tab 만큼 이동 |
|
b |
8 |
backspace : 뒤로 한 칸 움직임 |
|
r |
13 |
carriage return : 그 줄의 처음으로 이동 |
|
f |
12 |
form feed : 프린터의 종이를 다음 페이지로 넘김 |
|
a |
7 |
alert : 경고음 |
|
v |
11 |
vertical tab |
|
|