读书人

字符串复制算法容易实现

发布时间: 2012-09-10 22:20:13 作者: rapoo

字符串复制算法简单实现

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


#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';}


读书人网 >编程

热点推荐