博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串hash
阅读量:4653 次
发布时间:2019-06-09

本文共 485 字,大约阅读时间需要 1 分钟。

#include
//字符串hashaunsigned int hasha(char * url, int mod){ unsigned int n = 0; char * b = (char*) &n; for(int i = 0; url[i]; i++) b[i % 4] ^= url[i]; return n % mod;} int main(){ char str[] = "Hello World\n"; //char *str = "Hello World\n";是错误的 //原因:hello world 应该被分配到了常量区中,而声明的str指针在栈里 //而char str[] = "Hello World\n"; 字符串在栈中。 printf("%d", hasha(str, 25013));}

 

转载于:https://www.cnblogs.com/yujinghui/archive/2013/01/25/2876518.html

你可能感兴趣的文章
C# GUID的使用
查看>>
2D物体一直朝向某个2D物体(LookAt2D)
查看>>
面向对象编程里面的继承
查看>>
Handling duplicate form submission in Spring MVC
查看>>
Navicat 或者Java的JDBC通过SSH Tunnel连接MySQL数据库
查看>>
Android studio怎么去掉应用的标题栏
查看>>
[Cocos2D-X官方文档:解读CCArray类]
查看>>
为什么重写equals()方法就必须重写hashCode()方法
查看>>
深度优先搜索和广度优先搜索
查看>>
jquery有缝滚动
查看>>
关于TileBrush中Viewbox,Viewport以及Stretch,AlignmentX/Y的详细研究
查看>>
心态感言
查看>>
大数据——大价值、大机遇、大变革(全彩)
查看>>
常用SQL查询语句
查看>>
SQLiteOpenHelper类
查看>>
补充[BNDSOJ]小p的数列
查看>>
EhCache Monitor的使用
查看>>
UVa 541 Error Correction
查看>>
读APUE分析散列表的使用
查看>>
解决文件上传时,服务器中中文文件名乱码问题
查看>>