Below is the code
#include
# include "string. H"
# include "stdlib. H"
Char * my3cat (char * a, char * b, char * c)
{
Int 1 * n, I;
Char * p;
if (! A | |! B | |! C)
Return NULL;
1 * n=strlen (a) + strlen (b) + strlen (c);
If ((p=(char *) malloc (sizeof (char) * 1 * n + 1))=NULL)
{
Printf (" Application memory failure... \n");
Return NULL;
}
For (I=1 * n=0; A, [I]. P=a * n++ [1] [i++]);
for(i=0; B [I]; P=b * n++ [1] [i++]);
for(i=0; P=c * n++ [1] [i++]);
Return the p;
}
Int main (void)
{
[100] char a, b [100], [100], c * * p;
Printf (" Input 3 strings... \n");
The scanf (" % % % 100 s 100 s 100 s ", a, b, c);
Printf (" The result is % s \ n ", p=my3cat (a, b, c));
Free (p);
return 0;
}
CodePudding user response:
What call int 1 * n, I; ?Int n, I;
CodePudding user response:
Generally is a variable does not support this operation causes, or variable definitionsCodePudding user response:
Wrong a lot!
#include
# include "string. H"
# include "stdlib. H"
Char * my3cat (char * a, char * b, char * c)
{
Unsigned int n, I;
Char * p;
if (! A | |! B | |! C) return NULL;
//
N=strlen (a) + strlen (b) + strlen (c);
//
If ((p=(char *) malloc (n + 1))==NULL)
{
Printf (" Application memory failure... \n");
Return NULL;
}
//
n=0;
for(i=0; ifor(i=0; i for(i=0; i Return the p;
}
Int main (void)
{
[100] char a, b [100], c [100];
Char * p=0;
Printf (" Input 3 strings... <100 each! \n");
The scanf (" % s % s % s ", a, b, c);
P=my3cat (a, b, c);
If (p) printf (" The result is % s \ n ", p);
Free (p);
return 0;
}