#include "stdafx.h"
#include <stdlib.h>
#include <string.h>
#include <Windows.h>
#include <ctype.h>
char *mystrcat(char*s1p, char*s2p); // Prototype
int main(void)
{
char *string1 = malloc(80*sizeof(char));
char *string2 = malloc(80*sizeof(char));
printf("Enter in string 1");
scanf("%s", string1);
printf("Enter in string 2");
scanf("%s", string2);
char *mystrcat((string1,string2));
return 0;
}
char *mystrcat(char *s1p,char *s2p)
{
char *cat = malloc(2*80*sizeof(char));
int i = 0;
while(s1p[i]!='\o') {
cat[i] = s1p[i];
i++;
}
int j = 0;
while(s2p[j]!='\o') {
cat[i+j] = s2p[j];
j++;
}
return cat;
}
这是我到目前为止在您的所有帮助下得到的代码,我从上到下包括了所有内容,我正在使用 MSVS 2012 以及我发布此内容的原因,因为我在 'malloc' 上有一个错误,作为研究员的错误
3 IntelliSense: a value of type "void *" cannot be used to initialize an entity of type "char *" c:\Users\Sid\Documents\Visual Studio 2012\Projects\PORTFOLIO QUESTION 3\PORTFOLIO QUESTION 3\PORTFOLIO QUESTION 3.cpp 32