-
simple problem!!!?
Code:
#include <iostream.h>
#include <string.h>
#include <stdio.h>
char test(const char s1[10],const char s2[10]);
char test(const char s1[10],const char s2[10])
{
strcat(s1,s2);
cout<<s1;
return 'a';
}
int main()
{
test("hello", "there");
return 0;
}
I get the error - 'strcat' : cannot convert parameter 1 from 'const char []' to 'char *'Conversion loses qualifiers.
I've tried every combination. Do you know whats wrong? Thanks
-
How about just changing the function to this:
Code:
char test(const char* s1,const char* s2)
{
char* tmp;
strncpy(tmp,s1,10);
strncat(tmp, s2,10);
cout << tmp;
return 'a';
}
-
Why are you just returning 'a'. If you don't use it make the function void, cos you dont have to return anything.
-
i know, it was originally intended to return something, but for testing i did not need it so just put a filler.
-
Megatron, I get the warning char *tmp used without being initialized. If I try and exacute anyway I get an illegal operation on startup.
-
Code:
char test(const char* s1,const char* s2)
{
cout << s1 << s2;
return 'a';
}