On Mon, 11 Jun 2012 20:45:16 +0000 (UTC), jean francois
<> wrote:
> Hi All,
>
>I'm really sorry for the dumbness of my questions but I'm from the TP/Pas
>world.
>Before I get enough money to buy to good C/C++ compiler (for DOS/Win/NT,
Visual C++ 2010 Express is free from Microsoft. I'm sure there are
other free compilers which others may choose to mention.
>any suggestions
) and start learning C/C++, I need to translate a C
Be aware that C and C++ are two separate languages with just enough
commonality to insure newcomers become confused. Pick one language to
learn and stick with it until you are comfortable before trying to
learn the other.
>prog into TP.
>
>Here are the supid questions:
>
>1st:
>
>I've got p as a pointer on a CStruct. p = *CStruct. No matter was CStruct
>is.
>If the program does 'MyPointer = p++' what does this mean?
Except for void*, pointers in C always point to an object of a
particular type (so you can access that object by dereferencing the
pointer). Regardless of the type of the object, p++ will always cause
the pointer to point to the byte immediately following the object that
was pointed to. In the mathematical (as opposed to pointer
arithmetic) sense, p++ adds sizeof(object) to p.
>
>1) MyPointer = p; increment p of 1;
>2) MyPointer = p; Increment p of SizeOf(CStruct);
>3) increment p of 1; MyPointer = p;
>4) increment p op SizeOf(CStruct); MyPointer = p;
>5) something else?
>
>Second stupid question:
>
>'if !(a = b)' means
The ! operator evaluates to 1 if its operand evaluates to 0. If the
operand evaluates to any non-zero value, then the ! operator evaluates
to 0.
In your case, the operand is (a=b) which is an assignment expression.
An assignment expression evaluates to the final value of the left hand
operand (a in this case). As you note below, this probably should be
if !(a == b)
which is exactly equivalent to
if (a != b)
>
>1) if not a equal b (Hmmm I really don't believe this: equal is '==' not
>'=')
>2) a=b and if b=0 then....
>3) something else?
>
>Third stupid question:
>
>When I use a _fmalloc(size). Would that block be 'de-allocated' on exit? I
>couldn't find the 'dealloc' function in the prog.
_fmalloc is not a standard C function. For the standard malloc
function, the memory remains allocated until it is explicitly freed by
calling the standard free function.
When you say "exit" above, if you mean a function other than main
returning to the function that called it, then the allocated memory is
not deallocated. The standard does not address what happens when main
exits (returns to the operating system service that invoked the
program). Most modern general purpose operating systems will clean up
any residual resources, including allocated memory, when the program
exits. I would not be surprised if this did not happen on some
imbedded systems where main is never expected to exit.
>
>If someone knows where to find basic c++ help (*.hlp, *.doc,...) on the
>net...
C++ is discussed in comp.lang.c++, down the hall, third door on the
left, just past the water cooler.
--
Remove del for email