03 2016 档案

摘要:在ucos-II中,为了实现任务之间的同步,用到的同步机制有:信号量,邮箱和消息队列。其中这里我主要说下对信号量的使用经验。信号量在创建时, 调用OSSemCreate(INT16U cnt)函数。cnt为信号量的初始值。对cnt赋予不同的值,所起到的作用不同。如果Semp = OSSemCreat 阅读全文
posted @ 2016-03-24 11:25 ocean2015 阅读(620) 评论(0) 推荐(0)
摘要:信号量分为 :声明信号量、互斥信号量 转: ucos-ii学习笔记——信号量的原理及使用 #include "INCLUDES.h" #define TASK_STK_SIZE 512 char *s1="MyTask"; char *s2="YouTask"; INT8U err; //定义一个错 阅读全文
posted @ 2016-03-24 11:22 ocean2015 阅读(352) 评论(0) 推荐(0)
摘要:int main(void) { char a[50];int i=0;char *j;gets(a);//输入字符串j=a;while(*j!='\0'){j++;//指针指向下一个数组字符i++;}printf("字符串为%s,字符串的长度为%d\n\n\n",a,i); return 0;} 阅读全文
posted @ 2016-03-15 16:36 ocean2015 阅读(1233) 评论(0) 推荐(0)
摘要:int main(void) { FILE *fp; char ch,filename[10]; scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL) { printf("cannot open file\n"); exit(0); } c 阅读全文
posted @ 2016-03-15 14:22 ocean2015 阅读(279) 评论(0) 推荐(0)
摘要:int main(void) { char s[70]; FILE *fp; fp=fopen("123.txt","r"); if((fp=fopen("123.txt","w"))==NULL) //if 语句就是创建了一个空的.txt文件 { printf("Open the file fai 阅读全文
posted @ 2016-03-15 14:01 ocean2015 阅读(842) 评论(0) 推荐(0)
摘要:main(){   int i=8;   printf("%d %d %d %d %d %d ",++i,--i,i++,i--,-i++,-i--); } 运行结果 8 7 7 8 -7 -8 例2 main(){   int i=8;   printf("%d ",++i);   printf( 阅读全文
posted @ 2016-03-15 09:43 ocean2015 阅读(286) 评论(0) 推荐(0)
摘要:int main(void){ char ch; char str[80];   printf("Input a string: ");    //先输入字符串 gets(str);//get()   put()   这两个函数并列使用,前者就是从案件获取按键值,  后者是显示输出 puts(str 阅读全文
posted @ 2016-03-15 09:42 ocean2015 阅读(228) 评论(0) 推荐(0)
摘要:main(){ FILE *fp; char str[100],filename[10]; int i=0;if((fp=fopen("test","w"))==NULL) //{printf("cnnot open file\n");exit(0); }printf("lease input a 阅读全文
posted @ 2016-03-14 16:33 ocean2015 阅读(331) 评论(0) 推荐(0)
摘要://计算机器运行时间 long i = 10000000L;clock_t start, finish;double duration;//测量一个事件持续的时间printf( "Time to do %ld empty loops is ", i) ;start = clock();while( 阅读全文
posted @ 2016-03-12 11:54 ocean2015 阅读(211) 评论(0) 推荐(0)
摘要:char c; clock_t start,end; time_t a,b; double var; int i,guess; srand(time(NULL));loop: printf("DO YOU WANT TO PLAY IT .('y' or 'n')\n"); while((c=get 阅读全文
posted @ 2016-03-12 11:53 ocean2015 阅读(314) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> main() { unsigned int seed; /*申明初始化器的种子,注意是unsigned int 型的*/int k;printf("Enter a positive integer seed value: 阅读全文
posted @ 2016-03-11 16:18 ocean2015 阅读(252) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<malloc.h>#include<conio.h>#include<stdlib.h>#include "math.h"#include"time.h"#define NULL 0 main() { float a;srand(123456); 阅读全文
posted @ 2016-03-11 16:13 ocean2015 阅读(145) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<malloc.h>#include<conio.h>#include<stdlib.h>#include "math.h"#define NULL 0#define LEN sizeof(struct cle) struct cle { int n 阅读全文
posted @ 2016-03-11 10:36 ocean2015 阅读(265) 评论(0) 推荐(0)