字符串复制算法容易实现

字符串复制算法简单实现如题。很多情况下面试时容易考这个问题。#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';}