命令行历史:
F7弹出一个命令选择窗口,
F8输入少数几个字符后按F8自动补全,
F9弹出一个窗口输入命令序号
Dpath:
Allows programs to open data files in specified directories as if they were
in the current directory.
重定向
Chkdsk /r 2> diskerror.txt; 只将标准错误发送到文件中
2>&1; 将标准错误重定向到标准输出
(command1 & command2 ...) 命令分组功能
Hostname & ipconfig & netstat -a > current_cfg.txt这条命令只将netstat -a的输出发送到文件中
(hostname & ipconfig & netstat -a) > current_cfg.txt 这条命令会将所有输出合并后写入文件中
一些有用的工具(用法参考各自的帮助)
Typeperf 性能计数器
Wevtuitl 事件管理
Schtasks 管理计划任务
Diskpart 磁盘管理
Fsutil 磁盘维护
Defrag 磁盘整理
Where 文件查找
Gladwell notes:
“The idea that excellence at performing a complex task requires a critical minimum level of practice surfaces again and again in studies of expertise. In fact, researchers have settled on what they believe is the magic number for true expertise: ten thousand hours.”
玩聚上看见 神啊,C 终于开始支持 closure 了,吓了一跳啊,我的天啊!
#include <stdio.h> #include <Block.h> typedef int (^IntBlock)(); IntBlock MakeCounter(int start, int increment) { __block int i = start; return Block_copy( ^ { int ret = i; i += increment; return ret; }); } int main() { IntBlock mycounter = MakeCounter(5, 2); printf("First call: %d\n", mycounter()); printf("Second call: %d\n", mycounter()); printf("Third call: %d\n", mycounter()); Block_release(mycounter); return 0; } /* Output: First call: 5 Second call: 7 Third call: 9 */
从http://vscmdshell.codeplex.com/ 下载了VSCmdShell的最新版(其实很久没更新了),安装后在VS2008下无法使用Cmd shell,只能使用Powershell。很郁闷
上官网的Issue Tracker看了下,发现了相关的问题的描述http://vscmdshell.codeplex.com/WorkItem/View.aspx?WorkItemId=14645
其实是代码中硬编码了VS2005的注册表路径,而我没有安装VS2005,运行VSCmdShell后VS自然就崩溃了。解决方法只能自己下代码把注册表路径改掉重新编译,覆盖安装文件。这里要说的是,其实没必要完全按着官方的说明安装很多软件才能去编译源代码(我不写.NET代码,所以那些工具我都没有用过,当然也没有安装了)。打开解决方案,我们只要修改VSCmdShell2005项目下的CommandShellHost.cs文件中123行,把8.0改成9.0即可。编译时选择Debug配置,这个配置编译过程中不会调用我们没有安装的那些工具。当然,我们可以修改项目属性,让编译器优化代码。把生成的Microsoft.VSPowerToys.VSCmdShell.dll和Microsoft.VSPowerToys.VSCmdShell.Interfaces.dll复制到安装目录覆盖即可。
via: http://www.sunyzl.cn/read.php/96.htm
#include <tchar.h> static unsigned long g_crc32_table[256] = {0}; void init_crc32_table() { int i, j; for(i = 0; i != 256; i++) { unsigned long crc = i; for (j = 0; j != 8; j++) { if (crc & 1) crc = (crc >> 1) ^ 0xEDB88320; else crc >>= 1; } g_crc32_table[i] = crc; } } unsigned long crc32(char* buf, unsigned long len) { unsigned long oldcrc32 = 0xFFFFFFFF; unsigned long i; for (i = 0; i != len; ++i) { unsigned long t = (oldcrc32 ^ buf[i]) & 0xFF; oldcrc32 = ((oldcrc32 >> 8) & 0xFFFFFF) ^ g_crc32_table[t]; } return ~oldcrc32; } int _tmain() { init_crc32_table(); _tprintf_s(_T("crc32(\"StarsunYzL\") = %08X\r\n"), crc32("StarsunYzL", 10)); return 0; }