Click here to Skip to main content
16,004,898 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: one inportant thing Pin
LeeeNN12-Jul-05 6:57
LeeeNN12-Jul-05 6:57 
GeneralCXX0017: Error: symbol "buf_balance" not found Pin
LeeeNN11-Jul-05 14:09
LeeeNN11-Jul-05 14:09 
GeneralRe: CXX0017: Error: symbol "buf_balance" not found Pin
Indivara11-Jul-05 14:28
professionalIndivara11-Jul-05 14:28 
GeneralRe: CXX0017: Error: symbol "buf_balance" not found Pin
Indivara11-Jul-05 18:19
professionalIndivara11-Jul-05 18:19 
GeneralRe: CXX0017: Error: symbol "buf_balance" not found Pin
Bob Stanneveld11-Jul-05 20:40
Bob Stanneveld11-Jul-05 20:40 
Generalpointer increment Pin
Indivara11-Jul-05 13:07
professionalIndivara11-Jul-05 13:07 
GeneralRe: pointer increment Pin
Jose Lamas Rios11-Jul-05 15:58
Jose Lamas Rios11-Jul-05 15:58 
GeneralRe: pointer increment Pin
Indivara11-Jul-05 18:07
professionalIndivara11-Jul-05 18:07 
Jose Lamas Rios wrote:
1. (increment * count) might overflow in cases in which the for loop would work without problems

I don't think overflow is a problem. all values are well within range for all practical purposes

Jose Lamas Rios wrote:
2. If count is negative, the for loop won't alter the pointer; in the alternative, it will always be modified unless either increment or count is zero.

I didn't think of that. increment can in fact be either positive or negative (intentionally, to move the pointer forward or backward) but as you say, there are better ways, like using the absolute value of count


Jose Lamas Rios wrote:
Are you sure that's exactly how the code was written? Maybe if you give us some more context?

this is a part of code used to copy data from a bitmap. the pointer is the bitmap buffer, and increment is the number of bytes to move to the next line. count is used to skip certain lines.

and it was written like this

if (count != 0) {
    if (count == 1) {
        pointer += increment;
    } else {
        for (i = 0; i < count; i++) {
            pointer += increment;
        }
    }
}


I skipped the first if conditions in the original post...
they are used because count is often 0 or 1 (I think), but why use the loop? Confused | :confused:



- Indivara

"...This city desert makes you feel so cold.
It's got so many people but it's got no soul..."

- Gerry Rafferty, Baker Street

GeneralRe: pointer increment Pin
Bob Stanneveld11-Jul-05 20:53
Bob Stanneveld11-Jul-05 20:53 
GeneralRe: pointer increment Pin
Indivara11-Jul-05 21:11
professionalIndivara11-Jul-05 21:11 
GeneralRe: pointer increment Pin
Bob Stanneveld11-Jul-05 21:31
Bob Stanneveld11-Jul-05 21:31 
GeneralRe: pointer increment Pin
Indivara11-Jul-05 22:02
professionalIndivara11-Jul-05 22:02 
GeneralRe: pointer increment Pin
Bob Stanneveld11-Jul-05 22:06
Bob Stanneveld11-Jul-05 22:06 
Questionhow to scroll a dialog window Pin
g0ju11-Jul-05 11:31
g0ju11-Jul-05 11:31 
AnswerRe: how to scroll a dialog window Pin
Jose Lamas Rios11-Jul-05 16:19
Jose Lamas Rios11-Jul-05 16:19 
GeneralColored text in static text box Pin
Member 206903511-Jul-05 11:18
Member 206903511-Jul-05 11:18 
GeneralRe: Colored text in static text box Pin
PJ Arends11-Jul-05 11:27
professionalPJ Arends11-Jul-05 11:27 
QuestionHas anyone used the SpareLib++ code? Pin
adonisv11-Jul-05 9:17
adonisv11-Jul-05 9:17 
General!running 2 instances of app concurrently Pin
Member 206903511-Jul-05 8:29
Member 206903511-Jul-05 8:29 
GeneralRe: !running 2 instances of app concurrently Pin
Geert van Horrik11-Jul-05 8:33
Geert van Horrik11-Jul-05 8:33 
GeneralRe: !running 2 instances of app concurrently Pin
David Crow11-Jul-05 8:51
David Crow11-Jul-05 8:51 
Generalauto_ptr Pin
act_x11-Jul-05 7:45
act_x11-Jul-05 7:45 
GeneralRe: auto_ptr Pin
lemleyd11-Jul-05 8:30
lemleyd11-Jul-05 8:30 
GeneralRe: auto_ptr Pin
act_x11-Jul-05 8:51
act_x11-Jul-05 8:51 
GeneralRe: auto_ptr Pin
Jack Puppy11-Jul-05 10:40
Jack Puppy11-Jul-05 10:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.