运用指针连接两个数组

为什么无法运行


#include 
#include 
#include 
#include 
#include 
using namespace std;
char *strcat(char a[],char b[])
{
    char *pa=a;
    while(*pa!='\0')
    {
        pa++;
    }
    while(*b!='\0')
    {
         *pa=*b;
        b++;
        pa++;
    }
    *pa='\0';
    return a;
}


int main()
{
    char string3[60];
    char strPtr;

    char *s=strcat(string1,string2);

    char a[60]="there are 100 students in the class room." , b[60]="they study very hard." , c[200];

    char *s=strcat(a,b);

    puts(s);

    return 0;

}

string1,string2和s全都没定义
string3,strPtr,c全都没用上

char *s=strcat(string1,string2);
这里string1和string2哪来的?

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/7804643
  • 这篇博客你也可以参考下:<数据结构>折半查找算法实现
  • 除此之外, 这篇博客: 【算法分析与设计】经典排序算法实现中的 简单选择排序 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
        @Override
        public void selectSort() {
            int index, temp;
            //n-1趟的简单排序
            for (int i = 0; i < length; i++) {
                index = i;
                //在无序区查找最小记录,并置于新有序区最后一位
                for (int scan = i+1; scan < length; scan++) {
                    if (record[scan] < record[index]) {
                        index = scan;
                    }
                }
                if (index != 1) {
                    temp = record[i];
                    record[i] = record[index];
                    record[index] = temp;
                }
            }
        }
    
  • 您还可以看一下 唐世林老师的算法精选课程中的 什么是时间复杂度小节, 巩固相关知识点

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^