|
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...
|
|
|
|
|
About your second question:
AFAIK, most (all?) I/O-operations to a disk device is done by DMA, which stands for Direct Memory Access. This means that the CPU isn't involved, at least when it comes to move the data.
The amount of data to be written or read (at the lowest level) is exactly ONE disk sector (normally 512 bytes).
|
|
|
|
|
Disk operations are normally handled via DMAs. This allows the CPU to not get involved with physically moving the data from one place to another.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello
I'm writing a Win32 application using Visual C++. I want to create a button control that appears as coloured text only, with no button graphics or borders, but I want the text to depress as a button does when clicked. I have seen this kind of button in other applications.
I have created a bitmap button, but cant hide the button graphics/border. I have also placed a bitmap picture over an owner draw button, but the bitmap picture obviously wont depress.
I would appreciate any suggestions.
Thanks
John
|
|
|
|
|
I imagine you need to owner draw, which means you also need to handle the drawing of the depressed button.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes I imagined that too. Maybe I should have rephrased my question to ask - how to owner draw a bitmap button so that only the bitmap shows.
Thanks
John
|
|
|
|