thelamb 163 Posting Pro in Training

Google basically... if you want general information about C++ there are many good books, there is a sticky on this forum with a few good suggestions.

I THINK there are converters for C# to C++ as well, they won't do a good job on big chunks of code, but may help if you need a few functions 'translated'.

thelamb 163 Posting Pro in Training

No, notice the & sign before tc_a? This means tc_a is a reference.
So tc_a will reference p, which essentially makes them one and the same object.

Have you ever used references in function parameters? If not.. this is a good time to read about it ;)

thelamb 163 Posting Pro in Training

My excuse is that I was doing 5 things at the same time ;) - but well spotted.

I already mentioned in one of my posts that the return value of CreateMutex must be checked, and some error returned if it failed (e.g. the handle is NULL).

I've lost where this thread is going..

thelamb 163 Posting Pro in Training

I don't know what exactly you mean with 'if I use the code in WinMain it doesnt start' ... can you show us what you have?

The warning makes sense.. you are creating a variable that you never use. However, I guess IF something goes wrong with creating the mutex... you also do not want to run, so you should give an error message back after checking ghMutex.

thelamb 163 Posting Pro in Training

That's because the ascii value of 5 is 53 and of 6 is 54. 53+54=107.
When casting a char to an int, you get the ascii value of that character.

You're better off using frogboy's suggestion, or substract 48 from ch.

(see www.asciitable.com)

thelamb 163 Posting Pro in Training

Exactly - the intention of the move is fine(eliminating holes), but there can be allocated memory after what you're freeing right? So you will move this allocated memory to another address, but the person who allocated it will have no idea that you moved it - and just keeps on using it.

In my example the user of p20 assumes that he has 20 bytes, starting from the p20 pointer. But because p10 was free'ed, you moved the allocated 20 bytes back 10 bytes. So if now p20 writes 20 bytes, he will start writing in the middle of his 20-byte block and write 10 bytes past the end.

[ -10-  |     -20-     ]  <-- before
^p10     ^p20

[     -20-     ]          <-- after Free( p10 )
         ^p20

Ok the scaling is not perfect, but hopefully you got the idea ;)

thelamb 163 Posting Pro in Training

i is generally used for loop counters.. but no one is forcing you.
Specially if the body (the part between { and }) of the for loop is big, you might consider using a more meaningful name for the loop counter.

There are a lot of 'naming conventions'.. each with people who like it and people who protest it.

I generally use i if the body is small, else something like iLoopCount or simmilar. In any case... consider what your personal perference is and stick to it (be precise).
I personally have a strict naming convention.. e.g. pointers start with p, a 'char' starts with c, strings with sz, DWORDs with dw(or ul) etc.

thelamb 163 Posting Pro in Training

Well that's all nice and dandy, but no one is going to read through your source if you just ignore the rules this board has (How did you even miss the fact that you should use code tags?).

"I need a code in string as much as possible but if not, anything will do as long as it solves my problem."

People will help you if you ask a concrete problem, where are you stuck, what have you tried yourself. If you expect source code you're in the wrong place: ask concrete questions, try out what people tell you, if it works, celebrate your new knowledge, else try again until you got it.