|
U can also go for Mobile, Wireless & PocketPC related stuff.
But will bit difficult than RDBMS project
|
|
|
|
|
Hello and thanks for reading.
I was wondering if it is possible to make a message handler without the burden of the window.
See i want to make an asyncronous socket and it requires a message handler to use properly. I need something like a thread or something of that maner to use and make my ultimate class .
Again, thanks. Really appreciated.
Worlds stupidest question: Who am i?!
|
|
|
|
|
Take a look at CCmdTarget .
Nibu thomas
Software Developer
|
|
|
|
|
+-{Chimera}-+ wrote:
I was wondering if it is possible to make a message handler without the burden of the window.
I assume you mean a message queue, not a message handler. Yes, any thread can have a message queue. A queue is created the first time you call any User function that operates on the queue, like PeekMessage() or GetMessage() . You use PostThreadMessage() to put messages in the queue.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
float*[] xd = NULL;
float*[] yd = NULL;
float*[] zd = NULL;
xd = new float[200][4];
yd = new float[200][4];
zd = new float[200][4];
//
I found these not work. How to use pointer and new to work with 2D arrays ?
Please help, thanks
|
|
|
|
|
In C++ you have to allocate each dimension separately.
float** pparray = new float*[200];
for ( size_t i = 0; i < 200; i++ )
pparray[i] = new float[4]; And then you free the memory in the opposite order once you're done with it.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thanks that is great!
I need more help:
what "size_t" meant ? I thought "int" ?
Could you also give me the code for freeing the memery ?
So a complete set of code.
|
|
|
|
|
size_t is the correct type to use for the size of an object (the return value of sizeof ) or an array.
Free the memory in the opposite order - do the for loop, then free pparray last.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thanks that is great!
I need more help:
what "size_t" meant ? I thought "int" ?
Could you also give me the code for freeing the memery ?
So a complete set of code.
|
|
|
|
|
Using simple math, you can just use a single array. (Internally, that's exactly what's happening anyway.)
If we assume the array represents row and column, using your example the offset in a 1d array is (row * 4) + column .
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I thought 1_D[row * column] can be used for 2_D[row][column] ??
Please comment.
|
|
|
|
|
Look at it this way. Given array1[100][4] and array2[400]:
array1[0][0] = array2[0]
array1[0][1] = array2[1]
array1[0][2] = array2[2]
array1[0][3] = array2[3]
array1[1][0] = array2[4]
array1[1][1] = array2[5]
array1[1][2] = array2[6]
array1[1][3] = array2[7]
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
float*[] xd = NULL;
float*[] yd = NULL;
float*[] zd = NULL;
xd = new float[200][4];
yd = new float[200][4];
zd = new float[200][4];
//
I found these not work. How to use pointer and new to work with 2D arrays ?
Please help
|
|
|
|
|
i think program is easy, but i dont know how to get didtionary DATA file.
who know how they made the wikidictionary? onw word by one word?and by people? if so, how a big project~
i had seen many translator tool~ how they get the dictionary data file?
|
|
|
|
|
Such programs are extremely complicated. The problem is language is very contextual and anything more than simple sentences often requires a cultural understanding that cannot be programmed.
Now, if you are simply looking for simple word dictionary, then you simply collect lots and lots of words. But then you have to decide how to organize them and do word look ups. This can be quite complicated; to pluralize a word in English, for example, you don't always just add an 's', sometimes you add 'es', sometimes you drop the last letter and add 'ies'. So, you can either enter all words and forms of each word, the brute force method, or attempt to write an algorithm to determine the root of each word.
(I know many linguists, one of whom was responsible for the Larousse English-French electronic dictionary a few years back. He also worked on the Larousse pocket dictionary. He and another friend worked on the Collins electronic dictionaries from about ten years ago.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Lists of words exists on the web, those are usually free ( words themselves ), but all the associated information are copyrighted to each dictionnary ( definitions, examples, linguistic info, ... ), and rarelly you will find multi-lingual lists.
normally, those are build manually word by word, and definition created by linguists and language experts.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I want to develop a simple .dll, or application that deletes images from a usb digital camera. I don't have to use WIA, however I have been looking for tutorials or source code and I can't find any. MSDN has IWiaItem::DeleteItem, but I don't know how to use since it doesn't provide samples. The application/.dll has to be gui-less. ANY help would be greatly appreciated.
Mike - I love to program!
|
|
|
|
|
Hello all,
I have a question about doing an increment of a Void* pointer. I find out that I cannot do something like this
<br />
int i[10];<br />
void* p = i;<br />
int j = *((int*)(p++));<br />
The compiler will complain about the size of the pointer when I try to do an increment. My alternative approach is
<br />
int i[10];<br />
void* p = i;<br />
int j = *((int*)(((char*)(p))++));
First, I type cast the void* to char*, and then the compiler will know when I do the increment, it is going to add 4 bytes each time. I think this approach is ugly and might not compatiable with different platforms (when char* is not 4 bytes).
In case if people wonder why I try to do something like this is that I try to calculate the offset in an array by my self with only know the size of the element in the array in the array. However, I don't know how to add exactly n byte to a pointer when calculate the offset. The default increment behavior always requires to know the type of the pointer, which I don't know. Any idea?
Thanks!
Nacho
|
|
|
|
|
Rather than using a void*, I suggest using a BYTE*. you can then add whatever size you need without worrying about casting. You then simply increment the pointer by doing operations comparable to: p += sizeof(int);
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks, but is there any way which just use ANSI C++ standard type rather than BYTE? By using BYTE, we will have problem when we port the code in other platforms. Any idea?
Nacho
|
|
|
|
|
Use unsigned char . (Or use BYTE and on platforms that do not have it defined or typedefed, typedef it yourself.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
arey yar
that above one Immpossible.
v.raju
|
|
|
|
|
Why are you using a void pointer? If you want to point to an int why not use an int* ? Since void* can point to anything the compiler has no way of knowing the size of the object pointed to. In your code when you done p++ how far did you expect the pointer to be advanced?
Steve
|
|
|
|
|
The arithmetic for void* is not defined, so if you need pointer arithmetic you must do it with a type other than void*. However, the void* is guaranteed to be capable of holding any address on the machine, while other types of pointers do not guarantee it. But, for practical purposes on practical platforms with practical processors you may consider that all pointers are interchangeable.
This means that your code should be re-written to:
int i[10];
void* p = i;
int j = * (((int*)p)+1);
In other words: first cast the void* to int*. On practical systems this conversion does not produce any machine instructions, so it is not really executable code. This means that performance is not an issue.
After the cast the compiler treats the pointer as an int*, so the "+1" arithmetic is well defined (equivalent to "++"). It will be, in fact, equivalent to advancing the pointer to the address where the next int lies. In Win32 this will be an increment of 4 bytes. I've seen SOLARIS implementations where this same code would produce an increment of 8 bytes, to correctly handle its 8 byte int's.
The code I wrote is perfectly legal ANSI, compiles and runs correctly on all platforms, and I wouldn't consider it ugly. Your original code too, except that the precedence is not correct (you increment while the pointer is still void* and at that point it has no arithmetic logic).
Anyway, the second piece of code you propose should not compile. But that can be easilly fixed with "+1" instead of "++". But your reasoning changed in the second example, since you forced the cast from void* (that has no arithmetic logic) to char* (that has arithmetic logic) before incrementing, and so the increment is well defined. However, the increment amount is not correct, because sizeof(char) is 1 and not 4. The char*++ points to the next character (1 byte), instead of the next int (4 bytes). That should have resulted in a bad value for j. Didn't it?
Anyway, below is a piece of code you can test. I initialized "i" to show you that "j" gets a bad value (after fixing from "++" to "+1"). Also, you can see that "k" and "m" get the correct value. As a final note, the code for all 3 integers "j", "k", and "m" as the same instruction type and count, and their efficiency is the same. Of course "j" is wrong, but the compiler doesn't know that (however, some processors may generate exceptions when integers are not aligned, which may result in crashes or slow operating system exception handling).
The "ip" and "n" are not as efficient as the cast versions of "j", "k", and "m" in the debug version. In the release version they should be much more efficient, but the use of the "ip" is most adequate to situations where performance is not an issue, or you intend to do multiple accesses and manipulate the address of the pointer often, or you want the code to be clear. The manipulation could also be done with incrementing indexes in the "m" example, of course.
#include <stdio.h>
void main(void) {
int i[10]={ 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010 };
void* p = i;
int j = *((int*) (((char*)(p))+1) ); // Ugly
int k = *(((int*)p)+1); // Pretty
int m = ((int*)p)[1]; // Also pretty
int* ip=(int*)p;
int n = *++ip; // Even prettier
printf("j=%d, k=%d, m=%d, n=%d\n", j, k, m, n);
}
Rilhas
|
|
|
|
|
hi,
how will you display an icon on a button(CButton MFC VS2005 ), the icon is in say a fil c:\something.ico
|
|
|
|