strtok_r 과 strtok 의 차이점?
#include #include int main(int argc, char *argv[]) { const char delim[] = "\t\n ="; char *buf, *value_p, *lasts; char str[]="thsis is test"; buf = str; //value_p = strtok_r(buf, delim, &lasts); 1번 value_p = strtok(buf, delim); 2번 if( !value_p ){ fprintf(stderr, "wrong string \n"); return(-1); } fprintf(stdout, "string token is %s\n", value_p); return(0); } 1번으로 컴파일하면 "strtok_test.c", line 13: wa..
더보기
hole있는 파일 생성(creat, write, lseek)
/* hole있는 파일 생성 creat, write, lseek */ #include #include int main(void) { int fd; //파일만들다 fd = creat("holefile", 0644); //만든파일에 문자 쓴다. write(fd, "hello", 5); //현재 위치에서 10번째 뒤로 이동 lseek(fd, 10, SEEK_CUR); //문자쓴다. write(fd, "world", 5); //처음 시작점 부터 8192만큼 뒤로 이동 lseek(fd, 8192, SEEK_SET); //문자 쓴다. write(fd, "bye", 3); close(fd); return 0; } [출처] hole있는 파일 생성(creat, write, lseek)|작성자 지상렬
더보기