ChinaUnix.net
相关文章推荐:

strcpy原型声明

上次问到的 /** * strcpy - Copy a %NUL terminated string * @dest: Where to copy the string to * @src: Where to copy the string from */ char * strcpy(char * dest,const char *src) { char *tmp = dest; while ((*dest++ = *src++) != '\0') /* nothing */; return tmp; } 即使不是源代码我也想学学啊? 其它还有没有这种系统函数的实现可以学习一下的? 谢谢了!!!

by Advanceer - C/C++ - 2008-06-28 18:58:49 阅读(2222) 回复(9)

相关讨论

#include ; #include ; int main(void) { char *string="\0"; strcpy(string, "abcdefghi"); printf("string=%s\n", string); return 0; } 这个程序为何有错误!大家帮我看看

by yyjjss - C/C++ - 2004-05-21 09:01:15 阅读(1148) 回复(10)

char *str = NULL; str = (char*)malloc(sizeof(char)*10); strcpy(str, "hello"); str = "hello"; strcpy(str, "hello");和 str = "hello";有什么区别

by butterinsect - C/C++ - 2009-05-31 23:29:29 阅读(2142) 回复(15)

#include #include int main(void) { char buff[3]; strcpy(buff,"hello,world!"); printf("%s\n",buff); } 输出 : ./test hello,world! char *strcpy(char *dest,const char *src); 函数说明 strcpy()会将参数src字符串拷贝至参数dest所指的地址。 返回值 返回参数dest的字符串起始地址。 附加说明 如果参数dest所指的内存空间不够大,可能会造成缓冲溢出(buffer Overflow)的错误情况,在编...

by fasws - C/C++ - 2009-03-17 08:18:44 阅读(2912) 回复(15)

[code]#include #include char str[5]; char pad[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; int main() { printf("str's address before strcpy: %x\n", str); printf("pad's address before strcpy: %x\n", pad); strcpy(str,"1234567890abcdefghijklmnopqrstuvwxyz"); printf("str's address after strcpy: %x\n", str); printf("pad's address after strcpy: %x\n", pad); printf("strlen(str)...

by sysno - C/C++ - 2008-11-19 15:26:49 阅读(2874) 回复(21)

strcpy(host,inet_ntoa( *((struct in_addr*)h->h_addr))); warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast 为什么会警告 strcpy 需要的是两个char指针 而inet_ntoa返回的就是个char*啊 除非这么写 strcpy( host , (char*)inet_ntoa( *( (struct in_addr*)h->h_addr) ) ); 为啥

by houtinghua - C/C++ - 2012-11-27 14:53:19 阅读(2046) 回复(6)

#include #define L_BBXRBH32 2 #define NO 11 struct BH { char bbxrbh[L_BBXRBH32+1]; int iflag; }; int iLen=0; int i=0,j=0; int iNo=0; int iRec=0; char strBh[NO][L_BBXRBH32+1]; struct BH *lpBh=NULL; struct BH *lpBh1=NULL; iRec=NO; iLen=sizeof(struct BH); lpBh1=(struct BH *)malloc(iLen*iRec); printf("aa\n"); if(lpBh1!=NULL) { printf("fuck\n"); memset(lpBh1,0x00,iL...

by huxk - C/C++ - 2010-06-29 17:02:20 阅读(4777) 回复(19)

我在linux下用C编写一个程序,其中想用strcpy()函数将一个字符数组的值复制到一个指针数组(指向char类型),从而改变指针数组中第一个指针所指向的字符串....简述如下: char *to[]={"one","two","three"}; char from[]="four" strcpy(to[0],from); 我用上面的程序写了,编译可以顺利通过,但程序执行到strcpy(to,from)就自动退出,查了很多关开strcpy的资料均百思不得其解... 希望高手可以指点一下,谢谢!!

by es1024 - C/C++ - 2008-04-09 00:18:17 阅读(2413) 回复(13)

void *strcpy(void *dest ,const void *src,size_t n) { if(dest==NULL) dest=(char * )malloc(n); char *d=(char *)dest; char *s=(char *)src; for(int i=0;i!=n;i++) {*d++=*s++; } return dest; } 我想问一下这个程序有没有bug呢?我怎么运行不了呢?谢谢了. [ 本帖最后由 zhn636 于 2007-10-30 13:57 编辑 ]

by zhn636 - C/C++ - 2007-11-10 11:27:08 阅读(3830) 回复(23)

#include int main(int argc,char *argv[]) { char *src = "123456"; char dst[4]; strcpy(dst,src); cout< int main(int argc,char *argv[]) { char *src = "123456"; char dst[5]; strcpy(dst,src); cout<

by hlzembedded - C/C++ - 2007-10-09 09:21:54 阅读(1434) 回复(4)

有人说strcpy和strncpy遇到0就停止copy,这点与memcpy不同。但我试了结果却不是那样的。 strncpy和memcpy有什么区别? 1 #include 2 main() 3 { 4 char * s="0123456780901234567890123456789"; 5 char p[32]={0,}; 6 strcpy(p,s); 7 printf("p=%s\n",p); 8 } #./a.out p=0123456780901234567890123456789

by 源方 - C/C++ - 2007-07-11 22:18:11 阅读(2748) 回复(26)