|
and this code is work or not work
<br />
CFile file(_T("c:\\test.txt"),CFile::modeNoTruncate | CFile::modeWrite );<br />
file.SeekToEnd();<br />
file.Write(_T("test"),4);<br />
file.Close ();<br />
whitesky
|
|
|
|
|
How do you choose the socket number that you wish to use for a TCP connection?
Is there a band of numbers that you can use, if so what are they?
Thanks for any advice!
Mike
|
|
|
|
|
Mike,
There is no hard fast rule to selecting a port number for your own TCP services. In general the first 1024 are reserved for "well known" services and 49152 to 65535 are reserved for dynamically allocated and/or private port numbers.
Keep in mind where your service will be used, if it is a public service that anyone can connect to via the Internet, then you might want to be fairly selective on what port number you use. However if your service/server is to be used on a private network, then you can just about pick any port you want.
You can find a list of "well known" port numbers at:
http://www.iana.org/assignments/port-numbers[^]
Hope this helps.
|
|
|
|
|
Thanks for this.
My application(s) will be used on a private network, so there shouldnt be any issues with connection over the internet. Looking down the list, the first free block is 3825 - 3835, so I will probably look to us these.
Thanks for you help!
Mike
|
|
|
|
|
Hi
I'm writing some code that uses a set of purchased numerical algorithms. Unfortunately they use c function calls so any array that are passed to the functions are done so with pointers.
I usually use vectors rather than arrays so does anyone know how I can pass the vectors to these functions? Is it as simple as passing vector.front() or is there some other way to convert a c++ vector to a c array/pointer?
cheers
|
|
|
|
|
I usually use &myvector[0] for the array and myvector.size() for the array length.
|
|
|
|
|
vector.front() will work just fine. Just remember that it returns a reference, so take the address of its return value...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
This technique is fine for vector s but it's not safe for any of the other standard containers.
Steve
|
|
|
|
|
Correct, but he did say he was using vectors...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
In order to obtain a pointer to vector's values, you can try this: myVector.at(0) .
|
|
|
|
|
I have done the way u have suggested and didnt face any problem , since vector is also an array ,a self growing array and is continous we shouldn't face any problem .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
FarPointer wrote: we shouldn't face any problem
just don't assume the front of the vector will stay in the the same place if you add (or remove) elements to the vector. in other words, changing the vector may invalidate your 'pointer'.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Cheers everyone
I had thought that essentially vectors could be treated like pointers in this way, but I thought I'd check to see if others hade done it before.
Cheers for the tip on moving Chris, as it happens I'm just passing the vector, geting an answer and then that's it so it should be fine.
Thanks again
-- modified at 7:34 Thursday 22nd June, 2006 - typo
|
|
|
|
|
This technique is used by many. It's fine for vector . The capacity and reserve functions are even provided so the programmer can have some control over when reallocation occurs. Note however that it's can't be done with any of the other standard containers or the vector<bool> specialization.
Steve
|
|
|
|
|
I got a doubt how does a vector grow ,does it allocate using new or other mechanism .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Stephen Hewitt wrote: the vector<bool> specialization
I really wish implementers would just remove that specialization from their implementations.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
yes iam aware of that and especially in this case you are passing it to a library thats taking a pointer so a push_back wont hapen( its with vector) ,so he can use it here without any trouble .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Hello everybody,
I need to access some functions in a VB.NET dll from my VC++ application. The problem is that the dll doesn't export any functions like a common dll does. On a microsoft website I found a hint that looks like the .NET dll needs to implement a COM interface to fit my purposes, but I'm not shure.
Does anybody have more knowledge on this issue???
MS
|
|
|
|
|
Manfred Staiger wrote: the .NET dll needs to implement a COM interface to fit my purposes
Not entirly true. VC++ .NET compilers support "mixed mode". Use can use the /clr compiler switch to give your C++ project access to the .NET platform including components authored in nasty VB.NET Now it's not quite that simple but that is basically the idea. There are plenty of MSDN resources about project settings etc.
Manfred Staiger wrote: The problem is that the dll doesn't export any functions like a common dll does.
Correct, everything in .NET is a class. Using "mixed mode" you can create an instance and call the methods, or call the "static" methods of the class of course without an instance.
The Code Project (Managed) C++/CLI forum is dedicated to using the VC++ product with the .NET platform so your future questions on this subject should go there.
hope that helps
|
|
|
|
|
Hello all,
I am sure this is simple to do but I can't find it anywhere.
How do you do mutally exclusive toolbar buttons?
I mean you know the kind of toolbar buttons that when pressed stay pressed and at the same time, deselects all other toolbar buttons in the same grop?
You know in Microsoft Word, you can align you test to the left, center, right or justified. When you press one of those buttons the button stay pressed and also only one of those buttons can be pressed at any given time.
How do you achieve that?
Thanks.
Ciao
Giulio
|
|
|
|
|
I think you have to deal with button styles.
In your OnCreate handler for main frame, you can add a fragment like this:
mMyToolbar.SetButtonStyle(mMyToolbar.CommandToIndex(ID_BUTTON_1), TBBS_CHECKGROUP);
mMyToolbar.SetButtonStyle(mMyToolbar.CommandToIndex(ID_BUTTON_2), TBBS_CHECKGROUP);
mMyToolbar.SetButtonStyle(mMyToolbar.CommandToIndex(ID_BUTTON_3), TBBS_CHECKGROUP);
In this case three buttons will act like radio-buttons.
In addition, in order to make the buttons enabled, you have to provide event handlers for them.
See also: http://www2.cs.uregina.ca/~peckham/cs230b/source/Myword/toolbar.htm[^].
|
|
|
|
|
Hi again guys
i have this simple question
i have a string that holds some text
string text;
i want to search the string and replace any ("&nbs" with a space)
if i use the string.replace("&nbs"," ") it doesn't work what else do i need to specify for the function to work?
Any other ways to do it?
Thanks a lot
|
|
|
|
|
something like this:
find the first "&nbs"
copy the left part of the string (ie. before the &nbs) to a temp string
add a " " to the temp
in a loop:
find the next "&nbs" in the remaining (right side) string
if none found, add the remaing string to temp, and return temp
add the left part to the temp
add a " " to the temp
repeat the loop
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks a lot Chris Losinger
good clear steps thanks a lot
|
|
|
|
|
antonaras wrote:
if i use the string.replace("&nbs"," ") it doesn't work
What dosn't work? Does the compiler/linker complain? Is an exception thrown? Do any replacements happen?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|