본문 바로가기

분류 전체보기683

ctime_r ctime_r /* NAME asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, localtime_r - transform date and time to broken-down time or ASCII SYNOPSIS #include &lttime.h&gt char *asctime(const struct tm *tm); char *asctime_r(const struct tm *tm, char *buf); char *ctime(const time_t *timep); char *ctime_r(const time_t *timep, char *buf); struct tm *gmtime(const time_t *timep); struc.. 2016. 7. 9.
count #include #include int count( const char * str , char c ) int main( int argc , char **argv ) { char * str ="aa|bb|cc|11"; int i; if( i= count( str , '|' ) ) { printf( " %d \n", i ); } return 0; } int count( const char * str , char c ) { if( str == NULL ) return -1; int i,t=0; for( i = 0; i < strlen( str ); i ++ ) { if( str[i] == c ) { t++; } } return t; } 2016. 7. 9.
copy #include void copy(char *to, char *from) [CF-1-4] copy /* author : kyoung chip jang date : descript: */ int main( int argc , char ** argv ) { char str1[10]; char *str2 = "1234"; copy( str1, str2 ); printf(" str1 = %s \n", str1 ); return 0; } void copy(char *to, char *from) { int i = 0; while ((to[i] = from[i]) != '\0') ++i; } 2016. 7. 9.
replace replace [CF-1-3.1] /* author : kyoung chip jang date : descript: */ #include #include int main( int argc , char** argv ) { FILE* fpr,*fpw; char bufr[256],bufw[256]; char str1[] = "dog"; char str2[] = "rabbit"; char *p , *q; if( !(fpr=fopen("dog.txt","r"))) { printf(" cant file open\n"); return 1; } if( !(fpw=fopen("rabbit.txt","w"))) { printf(" cant file open\n"); return 1; } while(1) { fgets( b.. 2016. 7. 9.