码迷,mamicode.com
首页 >  
搜索关键字:assert    ( 2161个结果
判断一个字符串是否为回文字符串
#include<stdio.h> #include<assert.h> #include<string.h> intis_pal_str(constchar*p) { assert(p); intlen=strlen(p); constchar*start=p; constchar*end=p+len-1; while(start<end) { if(*start==*end) { start++; end--; } else { return0; } } ret..
分类:其他好文   时间:2015-11-13 23:46:04    阅读次数:405
【C语言】 实现strncat
#include<stdio.h> #include<assert.h> char*my_strncat(char*strDest,constchar*strSrc,inti) { char*start=strDest; assert((strDest!=NULL)&&(strSrc!=NULL)); while(*strDest++) ;//直到遇到\0跳出while循环 strDest--; while(i--) if(!(*s..
分类:编程语言   时间:2015-11-13 19:12:42    阅读次数:270
如何创建顺序表以及对标的一些操作
#include<stdio.h>#include<string.h>#include<memory.h>#include<assert.h>#defineMAX_SIZE100typedefintDataType;typedefstructSeqList{DataTypearry[MAX_SIZE];size_tsize;}SeqList;//定义一个结构体顺序表voidInitSeqList(SeqList*pSeq){memset(pS..
分类:其他好文   时间:2015-11-13 06:41:31    阅读次数:248
简单的动态线性表
头文件#ifndef__TEST_H__ #define__TEST_H__ #include<stdio.h> #include<string.h> #include<assert.h> #include<malloc.h> #defineMAX3//方便测试给一个小空间 typedefintdatatype; typedefstructSeqlist { datatype*_Array; size_t_size; size_t_ca..
分类:其他好文   时间:2015-11-12 18:14:33    阅读次数:260
C++11新特性之 Static assertions 和constructor delegation
C++11新特性继续。 Static assertion static_assert 是在编译时期的断言,作用不言而喻的。 语法是这样:static_assert ( bool_constexpr , string ) 其中: bool_constexpr: 常量表达式 string: 如果bool_constexpr表达式为false, 这个string就是编译时候报的错误。看...
分类:编程语言   时间:2015-11-12 11:55:49    阅读次数:226
【C语言】实现strcat
Strcat函数原型如下: char*strcat(char*strDest,constchar*strScr)//将源字符串加const,表明其为输入参数 { char*address=strDest;//该语句若放在assert之后,编译出错 assert((strDest!=NULL)&&(strScr!=NULL));//对源地址和目的地址加非0断言 while(*strDest)//是..
分类:编程语言   时间:2015-11-10 14:18:46    阅读次数:240
C++:检查出栈顺序的合法性
CheckSequence.cpp#include<iostream> #include<assert.h> usingnamespacestd; #include<stack> boolChecksequence(int*stackIn,int*stackOut,intlenIn,intlenOut){ assert(stackIn&&stackOut); if(lenIn!=lenOut)//两个序列长度不相等,不合法 retu..
分类:编程语言   时间:2015-11-10 14:15:25    阅读次数:201
模拟实现strstr函数
char*my_strstr(char*str1,char*str2){assert(str1);assert(str2);char*p=str1;char*pstr1=p;char*pstr2=NULL;while(*pstr1){pstr1=p;pstr2=str2;while(*pstr1&&*pstr2&&*pstr1==*pstr2){pstr1++;pstr2++;}if(*pstr2==‘\0‘){returnp;}p++;}returnNULL;}
分类:其他好文   时间:2015-11-10 01:52:03    阅读次数:186
编程实现strcpy函数功能
char*my_strcpy(char*dest,constchar*src)//src所指向内容不能被修改,dest所指向内容可修//改,加上const便于调试 { assert(dest!=NULL); assert(src!=NULL);//参数判断,有效性检测 char*ret=dest; /*while(*src!=‘\0‘); { *dest=*src; dest++; src++; } *dest=..
分类:其他好文   时间:2015-11-10 01:46:47    阅读次数:525
创建一个函数,实现库函数strstr的功能
★创建一个函数,实现库函数strstr的功能 #include<stdio.h> #include<stdlib.h> #include<assert.h> char*my_strstr(char*src,char*dst) { assert(dst); assert(src); char*p=src; char*q=dst; while((*dst)&&(*src)) { if(*src==*dst)//两指针内..
分类:其他好文   时间:2015-11-09 00:15:24    阅读次数:263
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!