목록펭귄's directory (180)
한땀한땀 정성들인 코딩
#include #include uid_t getuid(void); //현재 사용중인 아이디char* getuid(void); //현재 사용중인 아이디명 //root id는 0 #include #include struct passwd *getuid(uid_t uid); //id struct passwd *getpwnam(const char *name); //유저 아디명 pw_namepw_uidpw_gid // 그룹아이디 pw_dir // 홈 디렉토리 struct passwd *getpwent(void); // /etc/passwd에 있는 모든 유저 반환 void endpwent(void); //닫기 while( pw=getpwent()) //null을 반환할때 까지 돌면됨 #include void set..
헤더파일 : 함수선언, 구조체소스파일 : 함수정의, 전역변수static 전역변수명; //해당 파일에서만 접근이 가능하다.
struct{int a; //4바이트 short b; //2바이트 }test; sizeof(test) = 결과는?? 8byte 왜?? cpu의 빠른연산처리 (16byte캐시의 단위에 맞추면 연산이 떠 빨라짐) 구조체중 가장 큰 멤버변수 size에 맞춰서 커진다. pragma pack 전처리기 함수 #pragma pack(push,1);struct{int a; //4바이트 short b; //2바이트 }test1;#pragma pack(pop); struct{char a; //1바이트 short b; //2바이트 }test2; test1은 6byte
부동소수점 - 움직이는 소수점 예시3.14*(10^0) = 0.314*(10^1) 같은값이다.소수점을 지수에 따라 변환할수 있다. 32비트 msb(1bit) + 지수부(8bit) + 가수부(23bit) //msb는 부호 -127 ~ 128 //지수부의 실제 값에 -127해줘야함가수부 모양 2^-1, 2^-2, 2^-3 ......................... 2^지수부 값 + (가수부 값 + 1) //가수부는 1.~을 가져야 하므로 1을 더한다.
빅엔디안 : 내가 글씨쓰는 순서리틀엔디안 : 그 반대 메모리단위 1byte int a = 0x12345678;char b = 'A'; 78 56 34 12 순으로 저장 -> 리틀엔디안65 -> 엔디안 방식 상관없음 ,1byte니깐 *intel, amd cpu 리틀엔디안*네트워크 빅엔디안
#include int acces(const char *path,int mode); //파일 존재여부, mode는 0,1,2 존재,쓰기가능,읽기가능 int remove(const char* path); //제거 int rename(const char *oldname, const char *newname); //이름전환 int _chmod(const char *filename,int pmode); //속성 봐꾸기, pmode는 따로 참조 하자 int stat(consts char *filename, struct stat *buf); //파일의 정보 저장
#include #include int _open(const char *filename, int oflag); //성공 fd리턴 int _close(int fd); //성공 0리턴 _O_BINARY -바이너리 _O_TEXT -텍스트 _O_RDONLY -읽기전용 _O_WRONLY -쓰기전용 _O_RDWR -읽기기 _O_APPEND -커서를 맨끝으로 _O_CREAT -새로파일 생성 _O_SHORT_LIVE -임시파일 _O_TEMPORARY -close할때 파일 삭제 oflag값은 |로 여러개 줄수 있다. 입출력함수 int _read(int fd,void *buf,unsigned int count); //count만큼 버퍼로 읽음 int _write(int fd,const void *buf,unsigned i..
int fseek(FILE *fp,long offset,int orgin);enum {SEEK_SET,SEEK_CUR,SEEK_END} origin 커서의 위치|hello world! 선두 0seek_end에서 -5이동 -> hello w|orld! long ftell(FILE *fp) 커서위치 반환 // hello w|orld! //7반환
표준 스트림파일구조체 포인터타입항상 열려있는 스트림stdinstdoutstderr //잘 안씀 int i; scanf("%d",&i);fscanf(stdin,"%d",&i); char buf[30]; fgets(buf, 30, stdin);gets(buf); printf("%s",buf);fprintf(stdout,"%s",buf); fflushscanf("%d",&i);scanf("%c",&ch);//두번 입력이 안됨//buffer는 \n을 남겨둔다. c에는 \n이 들어감//키보드입력 -> memory(buffer) -> scanf가 buffer안에 있는 값을 읽음 int fflush(FILE *stream); //버퍼를 비어줌 리다이렉션표준 스트림 연결을 키보드에서 다른 장치(혹은 파일)로 봐꾸는 것..