전체 글

Programming/C & C++

C에서 날짜 출력하기

#include #include void main() { struct tm *t; time_t timer; // 시간측정 timer = time(NULL); // 현재 시각을 초 단위로 얻기 t = localtime(&timer); // 초 단위의 시간을 분리하여 구조체에 넣기 printf("현재 시간은 "); printf("%d년 %d월 %d일 %d시 %d분 %d초입니다.\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); }

Programming/C & C++

Const char* vs char* const

const int a = 1; // read as "a is an integer which is constant" int const a = 1; // read as "a is a constant integer" Both are the same thing. Therefore: a = 2; // Can't do because a is constant The reading backwards trick especially comes in handy when you're dealing with more complex declarations such as: const char *s; // read as "s is a pointer to a char that is constant" char c; cha..

Programming/C & C++

WindowsAPI C언어에서 파일 목록 가져오기

#include #include #include #include #define UNICODE void WCharToChar(const wchar_t* pwstrSrc, char pstrDest[]) { int nLen = (int)wcslen(pwstrSrc); wcstombs(pstrDest, pwstrSrc, nLen + 1); } int main(){ _wsetlocale(LC_ALL, _T("korean")); WIN32_FIND_DATA findFileData; HANDLE hFileHandle; // szDir에 뒤지고자 하는 디렉토리의 경로명을 준다. 예를 들면 "C:\\TEMP\\*.*" // 찾아진 파일의 속성은 findFileData의 dwFileAttributes를 살펴본다. hFil..

OS/Linux

umask를 이용해서 Default Permission 주기

umask 0022 = 755 for dirs & 644 for files. umask 0000 = 777 for dirs & 666 for files. umask 0027 = 750 for dirs & 640 for files. umask 0077 = 700 for dirs & 600 for files umask 0007 = 770 for dirs & 660 for files File의 경우 666, Directory의 경우 777을 기준으로 하며 default permission은 xxx - mask 값으로 한다.

Programming/Android

안드로이드 앱 위젯 셀 크기 구하기 (Android determine the actual pixel size of appwidget)

Display display; display = ((WindowManager) context.getSystemService(context.WINDOW_SERVICE)).getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); // cell size of a widget in portrait mode int xCellSize = 80; int yCellSize = 100; if (metrics.widthPixels > metrics.heightPixels) { // this means we're in landscape mode, so the cell sizes are adjusted xCel..

Programming/Android

Android Studio: Failed to complete Gradle execution

Problem: Failed to complete Gradle execution Cause: A fatal exception has occurred. Program will exit Solution Go to File -> Settings -> Gradle Input the following in the "Gradle VM options:" box: -XX:MaxHeapSize=256m -Xmx256m Hit apply and Android Studio should build your project successfully.

Programming/Android

안드로이드 매니페스트에서 버전 정보 가져오기

버전 명 String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; 버전 코드 int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;

Programming/Android

Android Studio Build

보호되어 있는 글입니다.

후유증
개인공간