|
execution will take place from right to left
first the address store in p gets incremented then the derefrence of the pointer(new address stored in p) will take place.
Finally the condition will be checked by while loop.If it is non zero statements enclosed by while loop braces will be exceuted otherwise not.
|
|
|
|
|
first Compare value of *P & then inc P , *p++ used no *(++p)
Iman Ghasrfakhri
|
|
|
|
|
execution will take place from right to left
first the address store in p gets incremented then the derefrence of the pointer(new address stored in p) will take place.
Finally the condition will be checked by while loop.If it is non zero statements enclosed by while loop braces will be exceuted otherwise not.
There was a mistake in my previous post.I have rectified it
//first the derefrence of the pointer will take place and then according to that value conditon is checked
//check the condition in while
if(*p)
{
p++;
// statements inside while loop are executed
}
else //when while loop fails
{p++;}
//statements after while loop
-- modified at 6:12 Thursday 27th October, 2005
|
|
|
|
|
The statement searches for the first byte after a zero terminated string.
It's useful when you're parsing a multistring, e.g. when you have a CFileDialog and the user has selected several files.
The response comes in a string where the files are separated with a single NULL char and the file list end with a double NULL char.
The statement mentioned would in such case find the next file name, or point to the second NULL char at the end of the list.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
If p initially points to a character string then after while(*p++); p points to the 0 character that terminates the string.
So it is semantically the same as
p = p + _tcslen(p);
|
|
|
|
|
Carsten Leue wrote: p = p + _tcslen(p);
Welcome to the gang! you too got it incorrect
it, actually, is equivalent to :
p= p + _tcslen(p) + 1
thanks!
|
|
|
|
|
It's a bummer! You are correct.
The loop ends if p points to the end of the string but p is still incremented.
Carsten
|
|
|
|
|
step 1. obtain value of object pointed to by "p"
step 2. increment "p"
step 3. if value evaluates to "true" then execute statement and continue with step 1
step 4. stop
|
|
|
|
|
equivalent code:
while (true)
{
bool done = *p == 0;
++p;
if (done) break;
}
|
|
|
|
|
Roger, Sunit, Ahz- you guys are awesome!
Does this example fit an obfuscated C contest?
thanks!
|
|
|
|
|
Lambu Jindu wrote: Does this example fit an obfuscated C contest?
no
|
|
|
|
|
please help if you can.
void i_make_an_object
{
object* object_ptr = new some_derived_object_class(some_parameter);
. . .
}
In the code above i have two things that need memory, the pointer object_ptr ,and the memory for the new object.
This things stored in registers,are they stored on stack(in the activation record i_make_an_object)?
dizzzzy
|
|
|
|
|
I'm not sure I understand the question. You're creating an object *, is this a managed C++ question, or vanilla C++ ?
In C++, when you call new, the memory for the new object is stored on the heap. The pointer itself, the variable which stores the memory address of this new object, is on the stack, I believe.
Here[^] is an article I found with google on the topic.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
can i ask you some questions that i have?
can i add two numbers and store the result without loading the operands into the cpu?
can a computer tell to the disk drive to move a standard block of bytes (say 512) into memory without the CPU handling each byte individually?
can i define 1024 registers?
dizzzzy
|
|
|
|
|
dizzzzy23 wrote: can i add two numbers and store the result without loading the operands into the cpu?
I don't see how - the CPU is what's going to add them, right ?
dizzzzy23 wrote: can a computer tell to the disk drive to move a standard block of bytes (say 512) into memory without the CPU handling each byte individually?
I'd expect them to travel in a block, but to be honest, this is way too low level for me.
dizzzzy23 wrote: can i define 1024 registers?
You should ask someone else this, my answer would be a guess.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am surprised you answerd that one!;)
The answers are:
1) No.
2) Yes. The CPU does not normaly read the bytes from the disk one byte at a time (that's an illusion). How much it reads (at a time) depends on the size of the registers.
(unless we have to write the assembly code to do it, we don't care!)
3) Don't be rediculus!
(Although, that makes me wonder if it might be possible on a supper computer)
INTP
Every thing is relative...
|
|
|
|
|
Whoooo! You need to figure out what the question is before you ask it.
INTP
The answer is 42. But what is the question?
|
|
|
|
|
what do you mean?
dizzzzy
|
|
|
|
|
I mean that your fist question did not realy explane what the problem is. I would need more to give a reasonable answer.
Oh, by the way, why are you doing this:
object* object_ptr = new some_derived_object_class(some_parameter);
Insted of this:
some_derived_objec_class object(some_parameter);
INTP
Every thing is relative...
|
|
|
|
|
first of all thanks for your time.i find a answer in my first question.
can you help me with these 3 above?
can i add two numbers and store the result without loading the operands into the cpu?
can a computer tell to the disk drive to move a standard block of bytes (say 512) into memory without the CPU handling each byte individually?
can i define 1024 registers?
dizzzzy
|
|
|
|
|
sorry
i just saw your response
about the 3) Don't be rediculus!
(Although, that makes me wonder if it might be possible on a supper computer)
can you be more specific why we could not?
thanks again
dizzzzy
|
|
|
|
|
You're welcome!
INTP
Every thing is relative...
|
|
|
|
|
can you be more specific why we could not define 1024 registres?
dizzzzy
|
|
|
|
|
because registers are a physical part of the CPU. You cant add or remove them with software
|
|
|
|
|
Thanks! I was starting to become dizzzzzzzzzzzzzy myself.
INTP
Every thing is relative...
|
|
|
|