Thanks for reply, I discovered the problem. It was that on setup when openning the serial port I was calling GetCommState() function before SetCommState(), so it was overwriting the DCB structure configuration, setting a wrong baud rate value. I fix it and now it's working wonderfully!
If you need a dynamic array (one that changes sizes), you need to allocate it dynamically on the heap.
In C++ you use new (along with corresponding delete after you're done with it).
In C you use malloc (along with corresponding free after you're done with it).
Failure to deallocate will result in memory leaks.
In addition to those options, you can use "containers", which are essentially classes that "contain" the dynamic array. A few of these options include std::vector, std::array, among others (most libraries including MFC have at least a couple of different container options).
If your original string is in Unicode then the MD5 hash will not be the same as the ASCII representation. If it is a prerequisite for what you want to do then convert your text to ASCII before hashing. Take a look at Example C Program: Creating an MD5 Hash from File Content[^] for further help.
Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.
Pointers are the same in both versions of the language; they point to elements or objects. In reality a pointer is merely a convenient way of addressing a portion of memory. for example:
char someArray; // allocate an array of characters
char* pItemOfArray = someArray; // create a pointer that 'points' to the first element of the array
// do something to fill the array with data
while (*pItemOfArray != '\0') // repeat some code while the array item contains some non-zero value
// do something with the item that the pointer points to, for example
*pItemArray = *pItemArray + 1; // add 1 to the item
pItemArray++; // update the pointer to point to the next item
} // and continue the loop
Simple. Learn ASM - then pointers will be the least of your concerns!
No, on a serious note (although, I am only 1/2 joking) - as jschell says, they're a tricky topic for most. There really isn't a direct counterpart in the physical world. You either get them, or you dont. (or you think you do, but dont )
One way to think of them may be to consider a pointer as a single entry in either the Table Of Contents or Index of a book. The pointer in itself doesn't tell you what the data is, it merely tells you where to find it. - The analogy breaks-down however, when you consider that the pointer doesn't tell you what it holds. Whereas the book-based counterparts tell you where to find the information, and give you a good clue as to what they hold.
An image of linked-lists may help for the concept of pointers to take root in your mind.