|
It already works that way. You create a socket that "listens" on port 2000 and when somebody "connects" to that port, you "accept" the connection (creating another socket) and the "listen" socket continues "listening" for more "connects". There are several socket interfaces, but they all basically work this way.
|
|
|
|
|
is it possible to add characters to the beggining or end of a string, ir so where can i learn, thanks a lot
|
|
|
|
|
|
I suspect by string you mean a char *, in which case the answer is strcat. Better to use std::string like this
string s = "fish";
s = "eat more " + s;
s = s + " to be more fit";
s now equals "eat more fisn to be more fit'.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
Christian Graus wrote:
s now equals "eat more fisn to be more fit'.
What's a fisn? Do they taste good?
And they still ran faster and faster and faster, till they all just melted away, and there was nothing left but a great big pool of melted butter
|
|
|
|
|
Peter Hancock wrote:
What's a fisn? Do they taste good?
Sure do, especially if you have them with chipn.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
hiya how do i get a handle to a dialog, as i want to set the title of the dialog dynamically using SetWindowText().
Also, is there really no way of deleting functions and variables in .NET?? can't believe that u can't delete them out of the project without going right to the .cpp and .h files and deleting them there...
thanks,
grahamoj..
|
|
|
|
|
|
Another solution is GetDlgItem().
Kuphryn
|
|
|
|
|
Actually, I´ve always programmed xla add-ins for Excel and have just started to be interested in c++. Most of the codes I program are finantial functions to be used in Excel and I wish to build a dll file with all of them, but Visualc++ IDE is still too complex for me. I wonder if someone could help me with a code sample. For instance, let´s suppose I define the simple following function:
double sums (double a, double b)
{
return a+b;
}
What steps should I follow to build the dll file?
How can I call the function from the VBA editor?
Can the spreadsheet user call it as Excel worksheet functions?
God bless you if you can help me. Thanks.
|
|
|
|
|
I'm looking for ideas on how to make a CWnd-derived window behave like a CDialog , especially in what concerns the DoModal behaviour. By this I mean encapsulating the whole window life cycle inside a function call. By calling the function or class method, the window would be created and destroyed at the user command. Only then the function / method would return.
Any ideas?
|
|
|
|
|
|
|
Hello,
I've designed my report by Crystal Report 8.5
And right now i'm using Crystal Report ActiveX in my project.
I'm looking for a way to show the report of a special record number, directly.
For example, i wanna show the report of Record number 4.
NEED FOR SPEED
Is there any way ?
Regards,
|
|
|
|
|
I have created a dll with a function that creates an array of structures. The calling application supplies a pointer that gets filled in by the dll call. The application then loops through the number of structures created by the dll call, and makes use of the info.
My plan was to have the application do the clean up as it looped through the returned data. When I call delete within the loop, I get a crash/assertion that I think is telling me that the objects were created on a different heap.
Is there a better way to do this? I don't want to have the applications call a enumerateXXX() type call where they have to identify a callback. I thought it would be best to just have them call something like this:
<br />
applications code:<br />
<br />
int nNum = 0;<br />
DSTRUCT *pds = NULL;<br />
mydllGetData(&nNum,&pData);<br />
for (int x = 0;x < nNum;x++){<br />
delete pds;
pds++;<br />
}<br />
<br />
dll code:<br />
mydllGetData(int *pNum,DSTRUCT &pds)<br />
{<br />
DSTRUCT *pNewDS = new DSTRUCT[15];<br />
*pds = pNewDS;<br />
*pNum = 15;<br />
<br />
}<br />
Thanks for any ideas you may have.
|
|
|
|
|
you can override new and delete for those objects and have them allocate from the global heap (via GlobalAlloc). that lets you keep your code looking like it does above. otherwise, as you've discovered, you can't share pointers allocated inside a DLL with the client application.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
Thank you for the reply.
This will be a stupid question:
I am familiar with how to override new/delete for classes, but not for struct's. Can this be done, or do I have to change my struct to a class?
Thanks again.
|
|
|
|
|
if these are C-style structs (typedef struct {....}), you could just allocate all the structs as one chunk of memory: GlobalAlloc(GPTR, sizeof(DSTRUCT) * numStructs). it's just like you would do with malloc.
if they are C++ structs (which are pretty much just classes with everything public by default), you can just override new/delete for that class (or struct).
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
There are two problems here:
1. You're trying to delete the elements of the array individually. You allocate the array as one block of 15 elements and then you try to delete each element one at a time. That's not going to work. You must free the entire array in one shot:
delete [] pData;
2. Allocating on the DLL and then freeing on the app is generally a bad idea. If the memory is not allocated/freed the same way across both modules, it will cause a crash. So it's best to stick with the policy of making the one who creates the memory be the one who frees it.
Add a mydllFreeData member:
void mydllFreeData(DSTRUCT* pds)
{
delete [] pds;
}
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Hi,
I have a function like this:
CStringArray CSearch::SearchNode(CString csDesiPin)
{
CStringArray a;
a.Add("test");
return a;
}
But when I try to compile there is an error:
error C2558: class 'CStringArray' : no copy constructor available
Why is that, what is wrong?
Thanks in advance!
|
|
|
|
|
Since you are not passing a pointer, a copy of the CStringArray is needed. If you derive a class from CStringArray, you can create a copy constructor to do this. An easier method would be to pass a pointer to a CStringArray, and not create a second CStringArray within the function.
|
|
|
|
|
I find it's better to pass in an object like this by reference as a parameter instead of returning a pointer. I usually return an error code instead.
As a rule, the standard collection of containers is a far better choice than the tinker toys that ship with MFC.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Christian Graus wrote:
As a rule, the standard collection of containers is a far better choice than the tinker toys that ship with MFC.
You never miss a chance, do you?
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Alvaro Mendez wrote:
You never miss a chance, do you?
Not if I can help it, no. I've been too quiet on this forum for some time, and *someone* needs to make a stand for righteousness....
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
Preach it brother! Halleluya!
By the way, I went to a Christian church for the first time a couple of weeks ago and saw the preacher "healing" a bunch of cancer-ridden people. As he was chanting over each one of them, I noticed that several of them were fainting and falling backwards, just like on TV!
What is your explanation for this behavior?
Also, I was only there for about 30 minutes -- got there late -- and I swear I must have counted about 30 Halleluyas coming from the preacher. Overall, it was an interesting experience.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|