C

C/C언어 코드 기록

외부 파일 실행 후 종료 될 때 까지 대기.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 char RunShellExecuteA(const char a_cmd[], const char a_path[]) { if (_access(a_path, 0) == -1) { printf("\n*********Error*********\n"); printf("경로명을 확인하세요.\n"); printf("***********************\n"); return 0; } // 실행을 위해 구조체 세트 SHELLEXECUTEINFOA info; ZeroMemory(&info, sizeof(info)..

C/C언어 코드 기록

메모장에 글쓰기

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #define _CRT_SECURE_NO_WARNINGS #include #include #include void main() { const char *path_txt = "경로입력\\test.txt"; FILE *p_file = fopen(path_txt, "at"); // 한글 포멧 setlocale(LC_ALL, "KOREAN"); wchar_t buf[1024]; wsprintf(buf, L"내용입력~"); fwprintf(p_file, L"%s", buf); fclose(p_file); } Colored by Color Scripter cs 또 다른 방법 FILE *p_file = _wfopen(L"경로입력\\..

C/C언어 코드 기록

C언어 파일 입출력 (텍스트 파일 생성)

12345678910111213141516171819#define _CRT_SECURE_NO_WARNINGS #include #include #include void main(){ const char *path_txt = "경로입력\\test.txt"; FILE *p_file = fopen(path_txt, "at"); // 한글 포멧 setlocale(LC_ALL, "KOREAN"); wchar_t buf[1024]; wsprintf(buf, L"내용입력~"); fwprintf(p_file, L"%s", buf); fclose(p_file);}Colored by Color Scriptercs

C/C언어 코드 기록

sprintf()함수 가변적으로 사용하기.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include int main() { char *p = "abc_"; char *buf = NULL; printf("before p >> %s \n", p); int num = 65533; int len = strlen(p); len += 1; // +NULL(1바이트) buf = (char *)malloc(len+5); // 자릿수 +5 sprintf(buf, "%s%d", p, num); printf("after buf >> %s \n", buf); free(buf); } Colored by Color Scripter cs

lwj789
'C' 카테고리의 글 목록 (4 Page)