|
-
Aug 31st, 2001, 03:10 PM
#1
Thread Starter
Hyperactive Member
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
Matt 
-
Aug 31st, 2001, 03:29 PM
#2
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';
}
-
Sep 1st, 2001, 06:14 AM
#3
Frenzied Member
Why are you just returning 'a'. If you don't use it make the function void, cos you dont have to return anything.
-
Sep 1st, 2001, 02:48 PM
#4
Thread Starter
Hyperactive Member
i know, it was originally intended to return something, but for testing i did not need it so just put a filler.
Matt 
-
Sep 1st, 2001, 02:58 PM
#5
Thread Starter
Hyperactive Member
Megatron, I get the warning char *tmp used without being initialized. If I try and exacute anyway I get an illegal operation on startup.
Matt 
-
Sep 1st, 2001, 04:52 PM
#6
transcendental analytic
Code:
char test(const char* s1,const char* s2)
{
cout << s1 << s2;
return 'a';
}
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|