in vb we use & , e.g.
variable & "whatever"
what about C?
Printable View
in vb we use & , e.g.
variable & "whatever"
what about C?
Not sure. lol
ok, but this gives me an error saying cann't add 2 pointers
Code:extern "C" int WINAPI Test(HWND, HWND, char *data, char *parms, BOOL, BOOL) {
_fstrcpy(data, data + "hi");
return 3;
}
Yeah I know I wasn't thinking when I posted. I'm half asleep. College killed me today. Let me look. Sorry.
Well in that code, the data variable is a pointer. Not sure if your familiar with those but that a memory address, not a value. You can't add two memory address together but you can add their contents using the indirection operator.
thanks for you help and replies mate,
"you can add their contents using the indirection operator"
whats the indirection operator?
The asterisk before the word data is the indirection operator. It tells the compiler that you're wanting to access a memory address. Let me know if you don't know how to add the contents and I'll show you.
ok thanks i just did this
_fstrcpy(data, *data + "hi");
and it returned something weird :confused:
a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
edit -----------
Im calling the function from my mIRC application, it all works fine when its like this
_fstrcpy(data, data);
so if i do //echo -a $dll(Test.dll, Test, Hello) in mIRC, it echos the word Hello.
Now changing it to _fstrcpy(data, *data + "hi");
i want it to echo the paramtered word with 'hi' appended on the end so
//echo -a $dll(Test.dll, Test, Hello) would be Hellohi
lol If that works then just put a space in before the word "hi" and then it should work.
If this line works, then try concatenating after the word "Hello"Quote:
//echo -a $dll(Test.dll, Test, Hello)
what you mean lol
like this?
_fstrcpy(data, *data + " hi");
yeah that works but im trying to do it through c++ for testing purposesQuote:
Originally Posted by GamerMax5
lol Try it and if it works then run with it.
when i do //echo -a $dll(Test.dll, Test, hello) it should echoCode:extern "C" int WINAPI Test(HWND, HWND, char *data, char *parms, BOOL, BOOL) {
_fstrcpy(data, *data + " hi");
return 3;
}
Hellohi
but it echos
a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
LOL, odd :confused:
:confused: :confused: :confused: :confused:
lol I think this is beyond my scope my friend. Sorry I couldn't be of more help.
no problem mate, thanks for all your help,
lets hope someone else might have a clue on this!
In C++, you should use the std::string class. The + operator is overloaded to allow you to add string literals as well as std::strings.
In C using character pointers (as in your first post) you can use sprintf() or strcat.Code:#include <string>
#include <iostream>
using namespace std;
// ...
string a = "hello";
string b = " there";
string result = a + b + " everyone";
Code:char somestring[64] = "hello";
char other[] = " there";
char result[256];
strcat(somestring, other); // somestring now equals "hello there"
sprintf(result, "%s %s everyone", somestring, "there"); // result now equals "hello there everyone"
ah thanks!!!
_fstrcpy(data, strcat(data, "hi"));
works perfect!
Wow.
Even though this wasn't my original post, I feel so much more relieved. lol
hey guys, when i do this
_fstrcpy(data, strcat(data, "hi")); it works fine
when i do this, it also works fine
lstrcpy(data, result); (with result being some data)
but with this i do this, i get error when i call the function from my mirc
lstrcpy(data, strcat("hi", result));
i want to concat "hi" to the beginning of the result, and put it into data to send back to mirc.. but it mIRC doesnt seem to like it, this works though
lstrcpy(data, strcat(result, "hi")); (but i want to concat "hi" at the begninning not the end)
*edit, i even tried lstrcpy(data, "hi" + result);
but that gives error saying it can't add 2 pointers