Click here to Skip to main content
15,914,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: JPEG to Cur Conversion Pin
Code-o-mat16-May-10 0:19
Code-o-mat16-May-10 0:19 
GeneralRe: JPEG to Cur Conversion Pin
ForNow16-May-10 7:10
ForNow16-May-10 7:10 
GeneralRe: JPEG to Cur Conversion Pin
Code-o-mat16-May-10 8:38
Code-o-mat16-May-10 8:38 
GeneralRe: JPEG to Cur Conversion Pin
ForNow16-May-10 8:51
ForNow16-May-10 8:51 
GeneralRe: JPEG to Cur Conversion Pin
Code-o-mat16-May-10 11:47
Code-o-mat16-May-10 11:47 
GeneralRe: JPEG to Cur Conversion --- Awicons did the trick Pin
ForNow16-May-10 8:35
ForNow16-May-10 8:35 
QuestionSolved - Two-Dimensional Array not reading right [modified] Pin
Frank Robertson15-May-10 16:20
Frank Robertson15-May-10 16:20 
AnswerRe: Two-Dimensional Array not reading right PinPopular
Luc Pattyn15-May-10 17:36
sitebuilderLuc Pattyn15-May-10 17:36 
Hi,

1.
you have an error in else if (( hand[count] > 13) && (hand[count] < 26))
what with the values 13, 26, 39 themselves?

2.
you could do the same with less code (and less bugs) by using division and modulo operators.
for positive integers, division yields the integer quotient, and modulo (aka remainder) yields the modulus (or remainder after division).

Example: instead of
if (hand[count] < 13)
    handColumn[count] = 0;
else if (( hand[count] > 13) && (hand[count] < 26))
    handColumn[count] = 1;
else if ((hand[count] > 26) && (hand[count] < 39))
    handColumn[count] = 2;
else if (39 < hand[count])
    handColumn[count] = 3;

do
handColumn[count] = hand[count]/13;

that is one line replacing 8, and eliminating the bugs.

And instead of
if ((hand[count] == 0) || (hand[count] == 13) || (hand[count] == 26) || (hand[count] == 39))
    handRow[count] = 0;
else if ((hand[count] == 1) || (hand[count] == 14) || (hand[count] == 27) || (hand[count] == 40))
    handRow[count] = 1;
...
else if ((hand[count] == 12) || (hand[count] == 25) || (hand[count] == 38) || (hand[count] == 51))
    handRow[count] = 12;

do
handRow[count] = hand[count]%13;

now replacing 26 lines.

3.
In general, any time you have a lot of lines that are almost identical, there probably is a smarter way to achieve the same with less code; sometimes it takes an operator, sometimes a loop. However, before committing to similar lines of code, rethink the matter.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

GeneralRe: Two-Dimensional Array not reading right Pin
Frank Robertson15-May-10 19:30
Frank Robertson15-May-10 19:30 
GeneralRe: Two-Dimensional Array not reading right Pin
Luc Pattyn16-May-10 1:07
sitebuilderLuc Pattyn16-May-10 1:07 
GeneralRe: Two-Dimensional Array not reading right Pin
Frank Robertson17-May-10 13:00
Frank Robertson17-May-10 13:00 
GeneralCongrats Pin
Luc Pattyn17-May-10 13:11
sitebuilderLuc Pattyn17-May-10 13:11 
GeneralRe: Two-Dimensional Array not reading right Pin
Iain Clarke, Warrior Programmer16-May-10 20:49
Iain Clarke, Warrior Programmer16-May-10 20:49 
AnswerRe: Two-Dimensional Array not reading right Pin
Aescleal15-May-10 22:42
Aescleal15-May-10 22:42 
GeneralRe: Two-Dimensional Array not reading right Pin
Frank Robertson16-May-10 0:51
Frank Robertson16-May-10 0:51 
QuestionLinux commands Pin
TTPadmin15-May-10 12:07
TTPadmin15-May-10 12:07 
AnswerRe: Linux commands Pin
markkuk15-May-10 12:17
markkuk15-May-10 12:17 
GeneralRe: Linux commands Pin
TTPadmin15-May-10 12:29
TTPadmin15-May-10 12:29 
GeneralRe: Linux commands Pin
CPallini15-May-10 12:39
mveCPallini15-May-10 12:39 
AnswerRe: Linux commands Pin
Paul M Watt15-May-10 20:24
mentorPaul M Watt15-May-10 20:24 
GeneralRe: Linux commands Pin
TTPadmin17-May-10 12:12
TTPadmin17-May-10 12:12 
GeneralRe: Linux commands Pin
TTPadmin19-May-10 12:19
TTPadmin19-May-10 12:19 
QuestionInteracting with a 3rd party application dialog window Pin
Still learning how to code15-May-10 11:55
Still learning how to code15-May-10 11:55 
AnswerRe: Interacting with a 3rd party application dialog window Pin
Paul M Watt15-May-10 20:37
mentorPaul M Watt15-May-10 20:37 
GeneralRe: Interacting with a 3rd party application dialog window - ANSWERED ! Pin
Still learning how to code15-May-10 21:28
Still learning how to code15-May-10 21:28 

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.