原创 strcat實現

char *my_strcat(char *dest,char *src) { char *tmp = dest; while(*tmp) tmp++; while(*src) *tmp++ = *src++; *tmp

原创 利用lseek製作任意大小的文件

#include <sys/types.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> int main(int argc,char *argv[]) {

原创 約瑟夫環(數組模擬實現)

#include <stdio.h> #include <stdlib.h> const int MAX_NUM = 300; int aLoop[MAX_NUM + 10]; int main(void) { int i,n,m;

原创 strlen實現

int my_strlen(const char *str) { int i = 0; while(str[++i]); return i; }

原创 strncat函數實現

#include <stdio.h> #define N 50 char *my_strncat(char *dest,char *src,int count) { char *tmp = dest; while(*tmp)

原创 strcpy簡單實現

char *my_strcpy(char *dest,char *src) { int i; for(i = 0; src[i]; i++) dest[i] = src[i]; dest[i] = '\0'; return d

原创 筆試小題

輸出 x = 3, y = 2 #include <stdio.h> int main(void) { int x = 1,y; y = x++ + x++; printf("x = %d, y = %d\n",x,y); re

原创 strchr函數的簡單實現

#include <stdio.h> #include <string.h> char *my_strchr(char *s,char c) { char *p = s; while(*p && *p != c) p++; i

原创 確定一個字符串在規定的字符串中的行列位置

#include <stdio.h> #include <string.h> int main(void) { char *str[] = {"Hello world","Hello hell","hello aka","hello

原创 (Linux高級編程)讀寫文件

#include <sys/types.h> #include <fcntl.h> #include <stdlib.h> #include <stdio.h> int main(int argc,char *argv[]) {

原创 約瑟夫環(鏈表實現)

#include <stdio.h> #include <stdlib.h> typedef struct node *link; struct node { unsigned char item; link next; }

原创 筆試小題

struct s1 {char *ptr,ch;union{short a,b;unsigned int c;};struct s1 *next;

原创 泛型算法的簡單應用

#include <stdio.h> typedef struct { const char *name; int score; }student_t; typedef int (*cmp_t)(void *,void *);

原创 strstr函數的簡單實現

#include <stdio.h> #include <string.h> char *my_strstr(char *str,char *substr) { int len1 = strlen(str); int len2 =

原创 二維字符串數組排序

#include <stdio.h> #include <string.h> void sort(char *name[],int n) { char *tmp = NULL; int i,j,k; for(i = 0; i