M
Maxx
I'm getting this error whenever i'm trying to compile this piece of C
code in Microsoft Visual C++
It's a string concatenation function from K&R exercise.I'm unable to
find the source of error it's reporting that error C2040 occurred with
the following message:
void(char *,char *) differs in levels of indirection from char*(char
*,const char *)
The code is:
#include<stdio.h>
#include<string.h>
#define ML 1000
void strcat(char *sp, char *tp)
{
/* run through the destination string until we point at the
terminating '\0' */
while('\0' != *sp)
{
++sp;
}
/* now copy until we run out of string to copy */
while('\0' != (*sp = *tp))
{
++sp;
++tp;
}
}
int main(void)
{
char s[ML]="Xecutioners";
char t[ML]="Return";
strcat(s,t);
printf("Here is the concatenated string(%s)\n",s);
return 0;
}
code in Microsoft Visual C++
It's a string concatenation function from K&R exercise.I'm unable to
find the source of error it's reporting that error C2040 occurred with
the following message:
void(char *,char *) differs in levels of indirection from char*(char
*,const char *)
The code is:
#include<stdio.h>
#include<string.h>
#define ML 1000
void strcat(char *sp, char *tp)
{
/* run through the destination string until we point at the
terminating '\0' */
while('\0' != *sp)
{
++sp;
}
/* now copy until we run out of string to copy */
while('\0' != (*sp = *tp))
{
++sp;
++tp;
}
}
int main(void)
{
char s[ML]="Xecutioners";
char t[ML]="Return";
strcat(s,t);
printf("Here is the concatenated string(%s)\n",s);
return 0;
}