|
Are you using http 1.1 protocol??? If so why dont you refer RFC2068 on http 1/1 protocol.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
|
i guess you can send data either using post or get method.
I guess get method is pretty straight forward. for post method you (and me) need more info how to do it (reference the rfc doc)
it would go like this.
Make the socket connection with the webserver.
Then depending upon POST or GET you send send the data.
I hope i am getting ur question correctly.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Hello, everyone!
I am looking for a safe and efficient way to use two dimensional arrays, better a library that I can use in C/C++.
Here is the way that I used before, allocate a pointer array, and then allocate memory pointed by each pointer in the array (size of each memory block pointed by each pointer may be vary and I always use an additional one dimensional array to record each of their size). But I find it is hard to manage (for example, release/free memory), because all the space the two dimensional array using is allocated on the heap and not on the stack, and
it is easy to result in memory leak if the management mechanism is not sound. And I want to supply an unified interface to client applications using the library, who uses the memory block as a two dimentional array, for example, A[i][j], and not using it as pointers, for example, *(A + i + j). Maybe to implement that function, I need a wrapper or a middle layer.
What I am looking for is a safe and efficient way to define, allocate space, manipulate and free (free part or all of the two dimensional array). Can anyone help? Are there some source codes or tutorials that I can make a reference?
Thanks in advance,
George
|
|
|
|
|
One of the safest ways would be to use standard library components.
std::vector<std::vector< your_type > > storage;
From a performance perspective this will be fine, unless you need to make lots of copies. Situations that involve many copies tend to come up in matrix maths. If that's the case it's worth looking for a library which uses templated operators to remove the overhead of the temporaries involved in such expressions. If that's the case look at boost::blas or blitz ( ? I think)
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks, Andrew buddy!
STL vector is useful in C++. But sometimes I need to use the same function in a pure C environment. What can I use in a pure C environment?
Have a nice weekend,
George
|
|
|
|
|
int main(int argc, char *argv[])
{
unsigned i;
// Declaration of the two-dimensional array
// as a pointer to pointer
//
char** array_2D;
const unsigned ROWS = 10;
const unsigned COLUMNS = 10;
// Allocate "main" array
//
array_2D = new char*[ROWS];
// Allocate each member of the "main" array
//
for (i = 0; i < ROWS; ++i)
array_2D[i] = new char[COLUMNS];
// Fill the 6th element with a string and print it
// out
//
strcpy(array_2D[5], "Hey there");
cout << array_2D[5] << endl;
// Deletion is performed in reversed order.
// Pay special attention to the delete[] operator
// which must be used to delete arrays (instead
// of the "simple" delete)
//
for (i = 0; i < ROWS; ++i)
delete[] array_2D[i];
delete[] array_2D;
return 0;
}
|
|
|
|
|
In C programming he should be using malloc and free , not new and delete .
- Nick Parker My Blog | My Articles
|
|
|
|
|
Yes, Nick buddy!
It is a constant rule.
Best regards,
George
|
|
|
|
|
Thanks for reply, Branislav buddy!
Your sample code is helpful. I have another question, how to use "array_2D" looking as a two dimensional array? I mean, in your sample, you use it as one dimentional array, for example, "array_2D[5]". I want to know how to use it looking as a two dimentional array, for example, array_2D [i][j]? Need to add additional wrappers or interface?
Best regards,
George
|
|
|
|
|
There are two dimensional array as like array_2D [i][j]. You can use something like this:
int** array_2D;
const unsigned ROWS = 10;
const unsigned COLUMNS = 10;
// initialize rows
array_2D = new int*[ROWS];
// initialize columns
for (int i = 0; i < ROWS; ++i)
array_2D[i] = new int[COLUMNS];
// fill 2d array with 0
for ( int y = 0; y < ROWS; y++ )
for ( int x = 0; x < COLUMNS; x++)
array_2D[x][y] = 0;
// after work try to make the free memory
for (i = 0; i < ROWS; ++i) { delete[] array_2D[i]; }
delete[] array_2D;
Regards,
|
|
|
|
|
Thanks, Branislav buddy!
It is a great idea!
Best regards,
George
|
|
|
|
|
please see the part below,i don't understand how does the function of the
scrollbar for the range and position (my book says that they use the integer of 16 bit)
note:
nMin=0;nMax=100
why was "nTemp1" calculated in that way in the program part below?
void CEx06aDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int nTemp1, nTemp2;
nTemp1 = pScrollBar->GetScrollPos();
switch(nSBCode) {
case SB_THUMBPOSITION:
pScrollBar->SetScrollPos(nPos);
break;
case SB_LINELEFT: // left arrow button
nTemp2 = (nMax - nMin) / 10;
if ((nTemp1 - nTemp2) > nMin) {
nTemp1 -= nTemp2;
}
else {
nTemp1 = nMin;
}
pScrollBar->SetScrollPos(nTemp1);
break;
case SB_LINERIGHT: // right arrow button
nTemp2 = (nMax - nMin) / 10;
if ((nTemp1 + nTemp2) < nMax) {
nTemp1 += nTemp2;
}
else {
nTemp1 = nMax;
}
pScrollBar->SetScrollPos(nTemp1);
break;
}
}
|
|
|
|
|
First, nTemp1 put outside the function and this variable is 0 first time (initialize). Every scroll changed exept SB_THUMBPOSITION and SB_THUMBTRACK ask for pScrollBar->SetScrollPos(nTemp1). Try to rearrange your function.
|
|
|
|
|
On the MSDN library web site it says if the uType is STRRET_WSTR it should be freed using the shell's allocator. But an example in an old Win32 Programmer's Reference ("Using PIDLs and Display Names") it doesn't seem to ever free it. Does the web site just mean if you create your own STRRET you should use the shell's allocator, or is there a leak in the example if its a
STRRET_WSTR and it should free pOleStr if uType = STRRET_WSTR (for all calls to GetDisplayNameOf, GetDetailsOf etc.)?
Also, does anyone know what the code might be for the StrRetToBuf or StrRetToStr functions? The code for printing the STRRET in my old reference example seems a bit outdated...
-thanks
|
|
|
|
|
Hi,
Just wondering what is the best way to create a repositry of libraries.
Basically now I have
c:\mylib\include
c:\mylib\lib
Then I might create dlls in say c:\mylib\devel
Then say I have
c:\mylib\devel\lib1
...
c:\mylib\devel\libN
Then in the post link setup I have 1 copy statement to copy the .h to c:\mylib\include
and two copy statements to copy the .lib and the .dll to c:\mylib\lib
Then I add c:\mylib\lib to control->panel->system->environment->path (so the dlls will load)
Then I create c:\mylib\libtest and add mini projects to test each of my libraries.
Basically the question are.
[1] Do I have to manually type the three copy statements in the post link setup each time?
I would like to have a generic stub which is used as I add each library. Can I use a batch file here with Macros?
[2] Is there a better way of doing this? What do most people do?
Regards,
Axe
|
|
|
|
|
I use this convention:
/Lib_x
/bin
/Debug
/Release
/inc
/src
/... The names of the libs and dlls in the /bin folder contain version information and a "D" suffix to indicate debug builds, eg: MyLib10.lib , MyLib10D.lib , etc. A post-build step in the main app's project copies whatever DLLs are needed to its own /Debug or /Release dir.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks ravi,
This is good information, however I think I am asking two questions in one.
The above is an excellent of way partitioning per library (module)
[1] How do you include the version number in the dll? Do you append it dynamically?
Do you have #define VERSION which you increment manually in the dll or is there a more automatic way of doing this?
[2] Having done something similar to the above per library I would like to create a repository of libraries. So basically I want to do something like put c:\mylib\include and c:\mylib\lib in the VS path settings and then I can use the libraries that I have created.
Basically something similar to the DirectX library. So what I did was to copy the .h in the library to c:\mylib\include and the .dll and .lib to c:\mylib\lib. So the .h that would be copied would be /inc // public interface (.h) in your example.
Would I have to create two copies of the library? I guess I would need to create
debug / release libraries.
So that would mean I would have those 3 statements + the other statements to copy the
dlls to the bin directory.
So do I really have to do the 5/6 post link copies every time I create a new library or can I have some generic script to jump into that directory and do the copy.
Regards,
Axe
|
|
|
|
|
axid3j1al wrote:
[1] How do you include the version number in the dll? Do you append it dynamically?
Funny you should ask! I just got done solving this problem. Will post a reply (or better yet, an article) soon.
axid3j1al wrote:
[2] Having done something similar to the above per library I would like to create a repository of libraries.
Gotcha. I guess I'd copy the public .h files to a global /inc folder and the libs and dlls to a global /lib (or /bin ) folder as you yourself suggested. The copy would occur in the post-build step for each library - i.e. it would occur every time you rebuilt a library (which is probably less often than rebuilding apps that use these libs).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
An article/reply would be great!
Thanks for you help.
At least im on the right track.
Regards,
axe
|
|
|
|
|
Note that this forum topic is not for advertising.
If your program was complete freeware, you should've created an article for it. Now, unfortunately, you should make a presentation of your application and send it to the Code Project staff, so it might get a place in the Product Showcase section.
But advertising under this forum topic is generally considered a bad thing, as there are many many questions to answer and posts to read already
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
A little while ago I asked if you could take the 7 .NET cd's and put it onto dvd. While its not on dvd yet it works on the hard drive.
Here is my initial question under the heading "Installing .NET"
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&fr=426#xx766942xx
By this I mean just mkdir c:\net\install
Then copy disk1-disk7 into net\install
Then run the components update bit.
Then run something like
c:\net\install\progra~1\Microsoft Visual Studio .NET\setup\setupmm\setup.exe
(something like that)
Then when it asks for disk1 point it to c:\net\install.
And yes I tried to compile something under install (which worked).
So on a machine with one cd/dvd drive you can listen to music and install .NET and its way quicker as well due to non cd swapping and the difference in speed between the hard drive and a cd mechanism.
So now you can just put that onto a dvd or just have a file server so that other users can easily install .NET unattended.
So sorry for asking such a basic question.
Regards,
|
|
|
|
|
Yeah i told you so.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
eh?
You said it couldn't be done.
I did it.
Am I missing something?
|
|
|
|
|
I said that you cant install .net by copying its files from one pc to another and tweaking the registry.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|