본문 바로가기

C 언어138

c_atoi c_atoi 1.소스 /* author : kyoung chip jang date : descript: */ #include int c_atoi(const char *s); int main( int argc ,char ** argv ) { char *line = "1234"; int i = c_atoi(line); printf(" atoi = %d \n", i ); return 0; } int c_atoi(const char *s ) { int i, n; n = 0; for (i = 0; s[i] >= '0' && s[i] 2016. 8. 9.
memory layout( for ubuntu 64bit) memory layout 1. 환경 2. memory_layout1.c#include int main(void) { return 0; } 3. memory_layout2.c( int g 추가 )#include int g = 100; int main(void) { return 0; } 4. memory_layout3.c( int stack 추가 )#include ing g = 100; int main(void) { int stack = 300; return 0; } 2016. 8. 3.
bi-directional sweep sort bi-directional sweep sort 1.소스 /* bisweepsort.c by mwberryman on metalshell.com * * Based on the sort algorithm in bubblesort.c which is * as simple as it gets in the sorting business. * * Added basic improvements to make a bi-directional sweep * sort. Added check to short-circuit sort operation as soon * as the program detects that the array is sorted. Limit * sweeping of values to the unsorted.. 2016. 8. 3.
time time 1.소스 #include #include #define SIZE 256 int main( int argc , char ** argv ) { char buf[256]; struct tm *loctime; time_t curtime = time(NULL); loctime = localtime(&curtime); fputs( asctime(loctime ) , stdout ); strftime(buf, SIZE , "today is %A, %B %d \n", loctime ); fputs( buf , stdout ); strftime(buf, SIZE, "the time is %I:%M %p \n", loctime ); fputs( buf , stdout); return 0; } 결과 hacker@u.. 2016. 8. 3.