문제
C에서 프로그램의 소요시간 측정하기
해결
#include <time.h>
clock_t start, stop;
start = clock();
~~~ 프로그램
stop = clock();
double run_sec = (double)(stop - start) / CLOCKS_PER_SEC;
<참조: http://egloos.zum.com/flowismylife/v/2761189>
2016년 11월 17일 목요일
2015년 11월 22일 일요일
2015년 11월 17일 화요일
std::ifstream
C의 FILE과 비슷한 역할을 하는 C++클래스
파일읽기용 std::ifstream과 파일에 쓰기용인 std::ofstream이 있음.
사용예
// 파일열기
ifstream myin("c:/a.txt"); 혹은
ifstream myin;
myin.open("c:/a.txt", ios::in | ios::binary); 형태로 연다.
// 읽거나 쓰기
myin >> i >> end;
myout << i << endl;
// 파일닫기
myin.close();
<참조: http://ra2kstar.tistory.com/147>
파일읽기용 std::ifstream과 파일에 쓰기용인 std::ofstream이 있음.
사용예
// 파일열기
ifstream myin("c:/a.txt"); 혹은
ifstream myin;
myin.open("c:/a.txt", ios::in | ios::binary); 형태로 연다.
// 읽거나 쓰기
myin >> i >> end;
myout << i << endl;
// 파일닫기
myin.close();
<참조: http://ra2kstar.tistory.com/147>
2015년 11월 11일 수요일
inline함수의 간단한 이해와 사용법
inline함수
- 보통 함수보다 약간빠른 수행속도를 가지지만, 그 코드크기만큼 메모리를 더 먹는다.
- 보통 함수보다 약간빠른 수행속도를 가지지만, 그 코드크기만큼 메모리를 더 먹는다.
사용법은
int func_name(int b)
{ return b+1; }
이란 함수가 있다면,
이란 함수가 있다면,
=>
inline int func_name(int b)
{ return b+1; }
처럼 앞에 inline이라고 써주면 된다.
혹은 헤더에 원래는
int func_name(int b);
만 있지만,
=>
int func_name(int b) { return b+1; }
이렇게 써도 inline으로 인식한다.
피드 구독하기:
글 (Atom)