码迷,mamicode.com
首页 >  
搜索关键字:strlen sizeof    ( 8171个结果
字符串移动,字符串为*号和26个字母的任意组合,把*都移动到最左侧,字母移动到右侧,顺序不变
#include #include #include #include #define MAX 256void move_stars(char* str) { int len = strlen(str) - 1; char* p = str + len; char* ...
分类:移动开发   时间:2014-07-16 19:15:02    阅读次数:200
第一周 从C走进C++ 006 动态内存分配
1. 用new 运算符实现动态内存分配第一种用法,分配一个变量:P = new T; T是任意类型名,P是类型为T * 的指针。 动态分配出一片大小为 sizeof(T)字节的内存空间,并且将该内存空间的起始地址赋值给P。比如:int * pn;pn = new int; * pn = 5;第...
分类:编程语言   时间:2014-07-16 18:39:49    阅读次数:193
iOS获取本地ip(基本通用)
- (NSString *)getLocalIP{ struct sockaddr_in sa; socklen_t len = sizeof(sa); if(getsockname(sockfd, (struct sockaddr *)&sa, &len)) { NSLog(@"获取失败!"); } return [NSS...
分类:移动开发   时间:2014-07-16 17:24:41    阅读次数:238
Writing Portable Programs
Size of Data TypesAlways use sizeof() to get the size of types(sizeof(char), sizeof(short), sizeof(int)...)Do not depend on the order of evaluation in...
分类:其他好文   时间:2014-07-16 15:51:58    阅读次数:191
iOS常用的加密算法
在iOS开发中,为了数据的安全经常对内容进行加密,在这儿我们对常用的加密算法进行了总结: 1、MD5 + (NSString *)md5Hash:(NSString *)str { const char *cStr = [str UTF8String]; unsigned char result[16]; CC_MD5( cStr, strlen(cStr), re...
分类:移动开发   时间:2014-07-14 18:17:16    阅读次数:265
字符串匹配算法
字符串朴素匹配法相等情况int index(const char * str1, const char * str2, int pos){ int i = pos; int j = 0; while(i = strlen(str2)) // matched and retu...
分类:其他好文   时间:2014-07-14 09:00:51    阅读次数:176
PHP-根据字符串和所用字体计算字符串所占宽高
今天由于用GD画图, 需要把一段文字在一个框内居中, 但是文字的宽度如果用strlen($str) * $font_size来计算的话, 由于文字不是等宽高的, 所以会导致偏离, 最后选用的GD库的imagettfbbox()函数, 其原型如下array ImageTTFBBox(int size,...
分类:Web程序   时间:2014-07-13 23:55:24    阅读次数:501
C++ 数组名作为函数参数 都是我的错
void func(char arr[100]){ coutusing namespace std;void myF( char arr[100]){ cout<<sizeof(arr)<<endl;}int main(void){ char arr[100]; myF(a...
分类:编程语言   时间:2014-07-13 21:15:06    阅读次数:175
Trie树
字典树查询 #include #include #include using namespace std; const int maxn = 30; typedef struct Trie{ int v; Trie *next[ maxn ]; }Trie; Trie root; void CreateTrie( char *str ){ int len = strlen( st...
分类:其他好文   时间:2014-07-13 17:17:39    阅读次数:336
字符串作为函数模版实参的意外情况
有时,当把c风格的不同字符串去实例化函数模版的同一个模版参数时,在实参演绎的过程中经常会发生 意想不到的事情,那就是编译失败,并报错类型不匹配。 正如下面的例子一样: #include using namespace std; /* *匹配测试 */ template int ref_fun(T & t1,T & t2) { return strlen(t1) - strlen(t2);...
分类:其他好文   时间:2014-07-13 17:04:42    阅读次数:208
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!