2011年4月15日

打开命令行提到的文件并处理参数

摘要: #include <stdio.h>#include <string.h>#include <errno.h>int main (int argc, const char * argv[]) { int argi; int aflag = 0; char *bval = NULL; for (argi = 1; argi < argc && argv[argi][0] == '-'; argi++) { char *p; for (p = (char *)&argv[argi][1]; *p != '\0 阅读全文

posted @ 2011-04-15 23:51 Cheney Shen 阅读(234) 评论(0) 推荐(0) 编辑

使用不规则数组(ragged array)和agetline()将整个文件读入内存

摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 extern char *agetline(FILE *); 4 FILE *ifp; 5 6 /* assume ifp is open on input file */ 7 8 char** lines = NULL; 9 size_t nalloc = 0;10 size_t nlines = 0;11 char *p;12 13 while((p = agetline(ifp)) != NULL) {14 if (nlines >= nalloc) {15 nallo 阅读全文

posted @ 2011-04-15 23:24 Cheney Shen 阅读(328) 评论(0) 推荐(0) 编辑

用C语言读入目录

摘要: 1 #include <stdio.h> 2 #include <sys/types.h> 3 #include <dirent.h> 4 5 int main() 6 { 7 struct dirent *dp; 8 DIR *dfd = opendir("."); 9 if (dfd != NULL) {10 while((dp = readdir(dfd)) != NULL)11 printf("%s\n", dp->d_name);12 closedir(dfd);13 }14 getchar();15 阅读全文

posted @ 2011-04-15 20:08 Cheney Shen 阅读(263) 评论(1) 推荐(0) 编辑

用C实现旋转棒进度条指示器

摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int i, lotsa = 100000; 7 printf("working:"); 8 for (i = 0; i < lotsa; i++) { 9 printf("%c\b", "|/-\\"[i%4]);10 fflush(stdout);11 }12 printf("\ndone.\n");13 return 0;14 } 阅读全文

posted @ 2011-04-15 17:13 Cheney Shen 阅读(428) 评论(1) 推荐(0) 编辑

用C实现百分比进度条指示器

摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int i, lotsa = 100000; 7 for (i = 0; i < lotsa; i++) { 8 printf("\r%3d%%", (int )(100L * i / lotsa)); 9 fflush(stdout);10 }11 printf("\ndone.\n");12 return 0;13 } 阅读全文

posted @ 2011-04-15 17:08 Cheney Shen 阅读(495) 评论(0) 推荐(0) 编辑

2011年3月17日

strtok函数相关理解

摘要: char * __cdecl strtok (char * string,const char * control){ unsigned char *str; const unsigned char *ctrl = control; unsigned char map[32]; int count; #ifdef _MT _ptiddata ptd = _getptd(); #else /* _MT */ static char *nextoken; #endif /* _MT */ /* Clear control map */ for (count = 0; count < 32; 阅读全文

posted @ 2011-03-17 20:02 Cheney Shen 阅读(331) 评论(0) 推荐(0) 编辑

2011年3月11日

xcode_4_and_ios_sdk_4.3__final相关下载地址

摘要: bt的是有人在下的xcode_4_and_ios_sdk_4.3__finalhttp://files.cnblogs.com/shenfei2031/xcode-4-and-ios-sdk-4.3-final.dmg.torrent.rarxcode4_gm2http://files.cnblogs.com/shenfei2031/xcode4gm2.torrent.rar(把后缀.rar去掉就是bt文件)gm2普通下载地址http://rsweb.cachefly.net/xcode_4_gm_seed_2.dmg电驴的地址似乎没人ed2k://|file|xcode_4_and_ios_ 阅读全文

posted @ 2011-03-11 13:26 Cheney Shen 阅读(1230) 评论(1) 推荐(0) 编辑

2011年3月10日

[创建型模式] Prototype

摘要: Prototype.h//// Prototype.h// Prototype//// Created by Cheney Shen on 11-2-20.// Copyright 2011年 __MyCompanyName__. All rights reserved.//#ifndef _PROTOTYPE_H_#define _PROTOTYPE_H_class Prototype{ public: virtual ~Prototype(); virtual Prototype* Clone() const = 0; protected: Prototype(); private: }; 阅读全文

posted @ 2011-03-10 03:05 Cheney Shen 阅读(158) 评论(0) 推荐(0) 编辑

[创建型模式] Singleton

摘要: Singleton.h//// Singleton.h// Singleton//// Created by Cheney Shen on 11-2-20.// Copyright 2011年 __MyCompanyName__. All rights reserved.//#ifndef _SINGLETON_H_#define _SINGLETON_H_#include <iostream>using namespace std;class Singleton{ public: static Singleton* Instance(); protected: Singleton 阅读全文

posted @ 2011-03-10 03:01 Cheney Shen 阅读(141) 评论(0) 推荐(0) 编辑

[创建型模式] AbstractFactory

摘要: AbstractFactory.h//// AbstractFactory.h// AbstractFactory//// Created by Cheney Shen on 11-2-20.// Copyright 2011年 __MyCompanyName__. All rights reserved.//#ifndef _ABSTARCTFACTORY_H_#define _ABSTRACTFACOTRY_H_class AbstractProductA;class AbstractProductB;class AbstractFactory{ public: virtual ~Abst 阅读全文

posted @ 2011-03-10 02:55 Cheney Shen 阅读(137) 评论(0) 推荐(0) 编辑

导航