码迷,mamicode.com
首页 >  
搜索关键字:strcpy    ( 952个结果
C语言 有关内存的思考题
1.void GetMemory(char *p) { p = (char *)malloc(100); } void Test(void) { char *str=NULL; GetMemory(str); strcpy(str,"Hello World"); printf(str); }请问运行Test函数会有什么样的结果? 程序编译可以通过,...
分类:编程语言   时间:2015-04-17 15:41:38    阅读次数:181
The C++ Programming Language 学习笔记 第6章 表达式和语句
1、关于strcpy函数。 书中说c风格的字符串尽量少用,strcpy这样的函数应该也要少用。这里讲这个函数主要是要通过本章课后练习第十题来讲一下前面提及的要点。巩固一下前几章的知识。写了一段,本来感觉自己写得不错了,结果和网上的一笔感觉还是差很多,也学到了很多,下面贴上网址供大家看看。...
分类:编程语言   时间:2015-04-16 23:13:21    阅读次数:109
项目1-深复制的体验(3)
#include #include using namespace std; class A { private: char *a; public: A(char *aa) { a = new char[strlen(aa)+1]; // strcpy(a, aa); // } ~A() { ...
分类:其他好文   时间:2015-04-15 09:39:59    阅读次数:100
编写说明strlen、strcpy、strcat如何实现的
随便定义一个char类型字符串数组,此以char string[] = "iphone";为例。实现strlenchar string[] = "iphone"; int i = 0; while (string[i] != '\0') { i ++; } printf("%d", i...
分类:其他好文   时间:2015-04-15 09:28:53    阅读次数:119
strcpy和memcpy的区别
strcpy和memcpy都是标准C库函数,它们有下面的特点。 strcpy提供了字符串的复制。即strcpy只用于字符串复制,并且它不仅复制字符串内容之外,还会复制字符串的结束符。已知strcpy函数的原型是:char* strcpy(char* dest, const char* src); m...
分类:其他好文   时间:2015-04-14 09:52:00    阅读次数:120
内存空洞
堆内存释放,是从堆顶开始。那么如果堆中间的一块区域,大部分内存都释放了,堆顶还有一些会怎么样呢? 我们来看个例子: #include #include #include #include int main() { char *p[11]; int i; for(i=0;i { p[i]=(char *)malloc(1024*2); strcpy(p[i],"12...
分类:其他好文   时间:2015-04-13 16:40:36    阅读次数:624
strcpy and memcpy
1. Inconsist length.char a3[2];char *a = "Itis "strcpy(a3, a); It is wrong. a3 will be correct, but a is missing. memcpy(a3, a, sizeof(char)* 2); It w...
分类:其他好文   时间:2015-04-12 13:13:36    阅读次数:220
VS2013下各种错误以及解决方案 (动态更新)
1、错误 1 error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. d:\codelibra...
分类:其他好文   时间:2015-04-10 13:38:41    阅读次数:102
字符串相关函数-strcpy()与strcmp()
一些小问题,避免出现低级错误。1、strcmp(s1,s2): 字符串指针不见'\0'不回头,这个常在与单个字符作比较时写着写着就忘了.char* p_ch1="this is an example!";char* p_ch2="h";printf("%d ",strcmp(p_ch1+1,p_ch...
分类:其他好文   时间:2015-04-09 23:29:57    阅读次数:144
my_strcpy
#include void my_strcpy(char* dest,const char* str) { if(NULL != dest || NULL != str) { while(((*dest++) = (*str++)))//注意运算的优先级 { ; } } *dest = '\0';...
分类:其他好文   时间:2015-04-09 17:24:20    阅读次数:89
952条   上一页 1 ... 71 72 73 74 75 ... 96 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!