摘要:
编程实现字符串的拷贝,不能用库函数。 一般的初学者或许能写出来,但是要写的很完美那就需要基本功了。 注意这里使用返回值为char*,是为了能够实现链式表达式。 strcpy拷贝了\0结束符,而strnpcy没有拷贝\0结束符,尤其注意。 比如:
阅读全文
posted @ 2015-06-27 10:17
奔跑的小河
阅读(139)
推荐(0)
摘要:
对于字符类型的指针真的有很多很多要注意的地方,而且他是String,CString等各种字符串相互转换的桥梁。 使用上稍不注意就会出错。 1.初始化 char* pstr = "hello world.";这是一个指向字符串常量的指针,也就是说hello wrold.是不能被修改的。因为它存...
阅读全文
posted @ 2015-06-24 22:58
奔跑的小河
阅读(4017)
推荐(0)
摘要:
C++实现内存的复制 通常我们使用深复制就是通过内存复制实现的,但是对象的复制涉及到基类派生类及其相关类的问题,这里不讨论。 目的为了能够明白内存复制的底层实现。 非常简单,但是还是能学到一些东西的。
阅读全文
posted @ 2015-06-24 22:51
奔跑的小河
阅读(692)
推荐(0)
摘要:
不同数据类型之间的转换可以说用得特别频繁,我也是经常查,索性就将其全部整理出来。 一、String和int、float、double的转换 源代码StringAndNumberConvertor:http://download.csdn.net/detail/z702143700/8785...
阅读全文
posted @ 2015-06-08 19:24
奔跑的小河
阅读(324)
推荐(0)
摘要:
题目: Given an array S of n integers, are there elements a,b,c, and d in S such that a+b+c+d = target? Find all unique quadruplets in the array which gi
阅读全文
posted @ 2015-06-07 17:06
奔跑的小河
阅读(160)
推荐(0)
摘要:
今天根据需求要从百度API中取出一些数据,这些操作包括:将坐标转换成百度坐标,根据转换的百度坐标进行特定的查询。 有需求的收藏下,免得下次手写浪费时间。 涉及到的操作有:JSON格式的字符解析,HTTP请求和获得请求数据,文件流的写入和读出等等。 奉上源代码,共享: 首先是入口函数: stat...
阅读全文
posted @ 2015-06-05 21:34
奔跑的小河
阅读(433)
推荐(0)
摘要:
题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three in...
阅读全文
posted @ 2015-05-31 15:44
奔跑的小河
阅读(103)
推荐(0)
摘要:
题目: Given an array S of n integers, are there elements a,b,c in S such that a + b + c = 0? Find all unique triplets in the array which gives the s...
阅读全文
posted @ 2015-05-31 12:10
奔跑的小河
阅读(155)
推荐(0)
摘要:
C++测试代码运行时间方法 方法一 最常用的执行时间测试方法,利用clock函数,精确度能达到ms级。 直接看代码吧,这样最直观: #include "stdafx.h" #include <ctime> #include <vector> #include <iostream> using nam
阅读全文
posted @ 2015-05-30 22:21
奔跑的小河
阅读(455)
推荐(0)
摘要:
指令周期 指令周期是CPU从内存取出一条指令并执行这条指令的时间总和,一般由若干个机器周期组成,是从取指令、分析指令到执行完所需的全部时间。 机器周期 机器周期也叫CPU周期,由于CPU访问一次内存所花的时间较长,因此用从内存读取一条指令字的最短时间来定义。在计算机中,为了便于管理,常把一条指令的执
阅读全文
posted @ 2015-05-30 20:54
奔跑的小河
阅读(1690)
推荐(0)