首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

字符串复制算法容易实现

2012-09-10 
字符串复制算法简单实现如题。很多情况下面试时容易考这个问题。#include iostreamusing namespace stdvo

字符串复制算法简单实现

如题。很多情况下面试时容易考这个问题。


#include <iostream>using namespace std;void strCopy(char *a, char *b);int main(){    char a[100], b[100];    cout << "Input a string :";    scanf("%s", a);    cout<<a<<endl;    strCopy(a, b);    cout<<b<<endl;    return 0;}void strCopy(char *a, char *b){    while(*(a)!='\0')    {        *(b++)=*(a++);    }    *b='\0';}


热点排行