随笔分类 -  [17] C语言程序设计

C语言程序设计,C Program。
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>char * strtolower(char * old){ char xx[1000]; int ii, length=0; length=strlen(old); for(ii=0; 阅读全文
posted @ 2018-01-12 23:43 emanlee 阅读(7087) 评论(1) 推荐(0) 编辑
摘要:头文件:#include fopen()是一个常用的函数,用来以指定的方式打开文件,其原型为: FILE * fopen(const char * path, const char * mode);【参数】path为包含了路径的文件名,mode为文件打开方式。mode有以下几种方式: 打开方... 阅读全文
posted @ 2015-04-11 18:25 emanlee 阅读(58043) 评论(0) 推荐(0) 编辑
摘要:#include #include char* asctime2(const struct tm *timeptr){ static const char wday_name[][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ... 阅读全文
posted @ 2014-07-25 11:39 emanlee 阅读(5843) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 4 char * string_search(char long_str[], char short_str[]) 5 {//author: emanlee 6 char *pl, *qs; 7 long is_identical, long_length, short_length; 8 long position, ii; 9 10 long_length=strlen(long_str); 11 short_length=strlen(short_str); 12 ... 阅读全文
posted @ 2013-12-15 11:54 emanlee 阅读(2683) 评论(0) 推荐(0) 编辑
摘要:strtok() 字符串分割函数strstr() 字符串查找函数范例#include main(){ char * s = "012345678901234567890123456789"; char *p; p = strstr(s, "901"); printf("%s\n", p)... 阅读全文
posted @ 2013-10-06 11:36 emanlee 阅读(627) 评论(0) 推荐(0) 编辑
摘要:编译简单的C程序 C语言经典的入门例子是HelloWorld,下面是一示例代码: #includeintmain(void){ printf("Hello,world!\n");return0;} 我们假定该代码存为文件‘hello.c’。要用gcc编译该文件,使用下面的命令: $gcc-g-Wallhello.c-ohello 该命令将文件‘hello.c’中的代码编译为机器码并存储在可执行文件‘hello’中。机器码的文件名是通过-o选项指定的。该选项通常作为命令行中的最后一个参数。如果被省略,输出文件默认为‘a.out’。 注意到如果当前目录中与可执行文件重名的文件已 阅读全文
posted @ 2013-07-13 14:48 emanlee 阅读(4217) 评论(0) 推荐(0) 编辑
摘要:#include #include void randomlize(int *a, int n){ int i = 0,j = 0, k = 0; for(i = 0; i < n; i++) { j = rand()%(n-i)+i; k = a[i]; a[i] = a[j]; a[j] = k; } }int main(void){ int i; int a[]={1,2,3,4,5,6,7,8,9}; randomlize(a,9); for(i = 0; i < 9; i++) { printf("%d ",a[i]); } return ... 阅读全文
posted @ 2013-07-13 08:52 emanlee 阅读(2419) 评论(0) 推荐(0) 编辑
摘要:#include#include #include "time.h" int main( void ) { long i = 1000000000L; clock_t start_time, end_time; double duration_time; start_time=clock(); while( i-- ) ; end_time = clock(); duration_time = (double)(end_time-start_time) / CLOCKS_PER_SEC; printf( "duration: %lf seconds\n" 阅读全文
posted @ 2013-07-13 08:26 emanlee 阅读(2208) 评论(0) 推荐(0) 编辑
摘要:# 动态创建二维数组示例#include "stdlib.h" #include "stdio.h" #include int main() { int i,j; int n; // 这个是需要指定二维数组的行数 int (*p)[10]; scanf("%d",&n);// 取得行数 // 动态生成二维数组,指定列数为10,如果想改,自己修改里面的参数,如果想定义n行2列就为: p=(int (*)[2])malloc(n*2*sizeof(int)); p=(int (*)[10])malloc(n*10*sizeof(i 阅读全文
posted @ 2013-07-12 16:20 emanlee 阅读(5148) 评论(0) 推荐(0) 编辑
摘要:C/C++ stack overflow, 怎样设置stack大小?解决方案 (1) vc6.0: project->setting->link->project options->Output->Reserve(2) 或者,把数组弄成全局变量或者malloc出来 阅读全文
posted @ 2013-07-12 11:35 emanlee 阅读(425) 评论(0) 推荐(0) 编辑
摘要:用VC++ 2008 编写C语言程序,编译出现错误: 预编译头文件来自编译器的早期版本,或者预编译头为 C++ 而在 C 中使用它(或相反) 解决方法: 建工程时 建立空项目 或者在项目设置里关闭预编译头的选项! 当 Visual C++ 项目启用了预编译头 (Precompiled header) 功能时,如果项目中同时混合有 .c 和 .cpp 源文件,则可能收到 C1853 编译器错误... 阅读全文
posted @ 2010-10-16 12:35 emanlee 阅读(34788) 评论(0) 推荐(0) 编辑
摘要:仅供参考 素数,水仙花,完数,选择排序,加密(字母循环移动),指针与一维数组,自定义函数的定义与调用,求阶乘,最大公约数和最小公倍数,文件读写,递归函数与递归调用,求及格人数或平均成绩或最大最小成绩,Fibonacci数列,指针变量做函数参数,数组做函数参数,结构体类型定义以及结构体变量的定义,联合,指针与结构体变量,二重循环,二维数组,自增运算++,自减运算--,基础知识(背诵),求累加和,交... 阅读全文
posted @ 2010-08-02 09:13 emanlee 阅读(655) 评论(0) 推荐(0) 编辑
摘要:6月17日,下午2:00-4:00,10-504 6月19日,下午4:00-6:00,9-422 (注:因四六级考试调整了地点) 6月21日,上午10:00-12:00,10-308(注:因监考冲突调整了时间) 阅读全文
posted @ 2010-06-14 12:10 emanlee 阅读(240) 评论(0) 推荐(0) 编辑
摘要:回车键,即键盘上的ENTER键,是一个比较有用的键,在文字编辑时,回车键的作用是换行,在输入网址时回车键的作用是“转到”,在执行DOS命令时,回车键的作用是执行…… 在标准键盘上,回车键一共有2个,一个在主键盘区的右边,Shift键的上面,一个在小键盘的右下角,加号键的下面。回车键的历史 关于“回车键”的来历,还得从机械的英文打字机说起。在打字机上,有一个部件叫“字车”,每输入一个单词,“字车”就... 阅读全文
posted @ 2010-06-07 21:33 emanlee 阅读(4170) 评论(0) 推荐(0) 编辑
摘要:\a:蜂鸣,响铃 \b:回退:向后退一格 \f:换页 \n:换行,光标到下行行首 \r:回车,光标到本行行首 \t:水平制表 \v:垂直制表 \\:反斜杠 \':单引号 \":双引号 \?:问号 \ddd:三位八进制 \xhh:二位十六进制 \0:空字符(NULL),什么都不做 注: 1,\v垂直制表和\f换页符对屏幕没有任何影响,但会影响打印机执行响应操作。 2,\n其实应该叫回车换行... 阅读全文
posted @ 2010-05-14 11:03 emanlee 阅读(97404) 评论(2) 推荐(6) 编辑
摘要:  #include "stdio.h" #include "conio.h" void main() {     printf("%.20f\n",0.1234567890123456789f);     getch(); }   观察在VC6,Win... 阅读全文
posted @ 2010-04-27 23:37 emanlee 阅读(13026) 评论(0) 推荐(0) 编辑
摘要:http://stackoverflow.com/questions/2548361/very-simple-c-program-wont-compile-with-vc-64 http://forums.nvidia.com/index.php?showtopic=65111&pid=398501&mode=threaded&show=&st=& He... 阅读全文
posted @ 2010-04-26 17:58 emanlee 阅读(446) 评论(0) 推荐(0) 编辑
摘要:下载:VC6显示行号的插件1. 如果你的VC安装在C盘,请拷贝文件VC6LineNumberAddin.dll到如下目录: C:\Program Files\Microsoft Visual Studio\Common\MSDev98\AddIns 2. 注册 双击VC6LineNumberAddin.reg进行注册。 3. 启用 打开vc6,菜单栏:Tools -> customize -... 阅读全文
posted @ 2010-04-26 17:54 emanlee 阅读(4992) 评论(2) 推荐(1) 编辑
摘要:1.Visual Assist(强烈推荐) http://www.wholetomato.com/        VA从5.0一直到现在的VAX,功能越来越强大,除了以前版本中的自动识别各种关键字,系统函数,成员变量,自动给出输入提示,自动更正大小写错误,自动标示错误等等以外,最新的版本中还在WorkSpace窗口中加入一个VA View... 阅读全文
posted @ 2010-04-26 17:21 emanlee 阅读(4832) 评论(0) 推荐(2) 编辑
摘要:当程序复杂时源代码会很长,如果把全部代码放在一个源文件里,写程序,修改、加工程序都会很不方便。程序文件很大时,装入编辑会遇到困难;在文件中找位置也不方便;对程序做了一点修改,调试前必须对整个源文件重新编译;如果不慎把已经调试确认的正确部分改了,又会带来新的麻烦。在实践中人们体会到:应当把大软件(程序)的代码分成一些部分,分别放在一组源程序文件中,分别进行开发、编译、调试,然后把它们组合起来,形成整... 阅读全文
posted @ 2010-04-26 15:42 emanlee 阅读(5737) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示