包含文件:string.h函数名: c_str功能:string转char数组用法:char
c[20]; string s="1234"; strcpy(c,s.c_str()); 这样才不会出错,c_str()返回的是一个临时指针,不能对其进行操作
分类:
其他好文 时间:
2014-05-24 07:28:57
阅读次数:
212
出题:请实现给定String的类定义;分析:注意检查标准类构造注意事项;解题: 1 #include
2 #include 3 /** 4 * 检查是否需要构造函数 5 * 检查是否需要无参构造函数 6 * 检查是否需要成员变量(函数)私有 7 *
检查是否需要在构造函数预初始化成员变量...
分类:
其他好文 时间:
2014-05-19 10:32:35
阅读次数:
217
//普通方法
void strcpy1(char str1[], char str2[]){
int i = 0;
for (; str2[i] != '\0'; i++){
str1[i] = str2[i];
}
str1[i] = '\0';
}
//简练方法
void strcpy2(char str1[], char str2[]){
int i = 0;
whil...
分类:
其他好文 时间:
2014-05-18 09:47:40
阅读次数:
273
#include
#include
#include
#include
#include
// #include
int main(void){
char str1[]="This is the first string";
char str2[]="That is the other string";
// printf(strcpy(str1,str...
分类:
其他好文 时间:
2014-05-15 01:39:40
阅读次数:
348
1 char * strcat(char * dest, const char * src)
{ 2 assert(dest != NULL && src != NULL); 3 char * p = dest; 4 while (*p)
5 p++; 6 ...
分类:
其他好文 时间:
2014-05-13 20:30:10
阅读次数:
272
函数名: strcpy功 能: 拷贝一个字符串到另一个用 法: char
*stpcpy(char *destin, char *source);程序例:#include #include int main(void){ char
string[10]; char *str1 = "abcdefgh...
分类:
编程语言 时间:
2014-05-07 18:01:41
阅读次数:
487
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
char*ReplaceString(constchar*srcStr,constchar*src,constchar*dest)//替换字符串,获得文件路径
{
char*ptr;
intlen=strlen(srcStr);
ptr=(char*)malloc(sizeof(char)*len+1);
strcpy(ptr,srcSt..
分类:
编程语言 时间:
2014-05-05 12:29:50
阅读次数:
422
1,指针没有指向一块合法的区域1指针没有初始化12345678910111213#include #include struct aa{char
*pa;char c;}ssa,*ssb;void main(){strcpy(ssa.pa,"abc");printf("%s \n",ssa.pa);...
分类:
其他好文 时间:
2014-05-04 11:38:09
阅读次数:
278
(string.h)这个文件夹主要是定义了几个对字符串和数组进行操作的函数。功能很强大。下面是重要函数:strcpy、strncpystrcpy,strncpy这两个函数是对字符串的复制,很常用。memcpy函数原型:void
* memcpy ( void * destination, const...
分类:
其他好文 时间:
2014-05-03 23:10:14
阅读次数:
310