Click here to Skip to main content
15,920,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CStringArray Pin
BlackDice2-Dec-04 7:53
BlackDice2-Dec-04 7:53 
GeneralRe: CStringArray Pin
BlackDice2-Dec-04 7:54
BlackDice2-Dec-04 7:54 
GeneralRe: CStringArray Pin
David Crow2-Dec-04 10:32
David Crow2-Dec-04 10:32 
GeneralRe: CStringArray Pin
Graham Bradshaw2-Dec-04 11:09
Graham Bradshaw2-Dec-04 11:09 
GeneralSubtraction of Integer on Character Array [C++] Pin
Shaitan002-Dec-04 6:49
Shaitan002-Dec-04 6:49 
GeneralRe: Subtraction of Integer on Character Array [C++] Pin
Maximilien2-Dec-04 7:05
Maximilien2-Dec-04 7:05 
GeneralRe: Subtraction of Integer on Character Array [C++] Pin
RChin2-Dec-04 7:11
RChin2-Dec-04 7:11 
GeneralRe: Subtraction of Integer on Character Array [C++] Pin
John R. Shaw2-Dec-04 17:23
John R. Shaw2-Dec-04 17:23 
Shaitan00 wrote:
tmpbuf = tmpbuf - arith;

Eek! | :eek: DON'T DO THAT!
You are attempting to change the address of tmpbuff from 0x0012c434 to 0x0012c432. You cann't do that since tmpbuf is an array (not an l-value) and not just a pointer. If it was a memory pointer it would still be wrong (crash city)!

char buf2[5];
strcpy(tmpbuf,_itoa(atoi(tmpbuf)-arith),buf2,10));

This would do it, but there is no error checking. What would happen if the number contained more than 4 digits? I recommend you use a larger buffer, since you are working with intergers, the buffer should be a minimum of 12 (10 digits + 1 for '\0' + 1 for '-') characters. That assumes that the value will be no more than a 32 bit number, in the near future it will be a 64 bit number and the code will break.

Sigh | :sigh: Sorry about that, but when I see code like that my heart skips a beat.

INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
GeneralScrolling in CRichEditView Pin
zhngmm2-Dec-04 5:46
zhngmm2-Dec-04 5:46 
GeneralExport Outlook Mailboxes programmatically Pin
Kri52-Dec-04 4:55
Kri52-Dec-04 4:55 
GeneralInterrupts & Timers Pin
sweep1232-Dec-04 4:50
sweep1232-Dec-04 4:50 
GeneralRe: Interrupts & Timers Pin
Antony M Kancidrowski2-Dec-04 5:35
Antony M Kancidrowski2-Dec-04 5:35 
GeneralRe: Interrupts & Timers Pin
sweep1232-Dec-04 5:44
sweep1232-Dec-04 5:44 
GeneralRe: Interrupts & Timers Pin
Antony M Kancidrowski2-Dec-04 6:19
Antony M Kancidrowski2-Dec-04 6:19 
GeneralUpgrade DB Pin
Ouenstreet2-Dec-04 4:24
Ouenstreet2-Dec-04 4:24 
GeneralRe: Upgrade DB Pin
David Crow2-Dec-04 6:01
David Crow2-Dec-04 6:01 
GeneralRe: Upgrade DB Pin
Ouenstreet3-Dec-04 9:56
Ouenstreet3-Dec-04 9:56 
GeneralRe: Upgrade DB Pin
David Crow3-Dec-04 10:09
David Crow3-Dec-04 10:09 
GeneralPlagarisms Pin
Anonymous2-Dec-04 4:21
Anonymous2-Dec-04 4:21 
GeneralRe: Plagarisms Pin
David Crow2-Dec-04 5:30
David Crow2-Dec-04 5:30 
GeneralRe: Plagarisms Pin
Blake Miller2-Dec-04 10:38
Blake Miller2-Dec-04 10:38 
GeneralRe: Plagarisms Pin
PJ Arends2-Dec-04 11:04
professionalPJ Arends2-Dec-04 11:04 
Generalsoundcard line in data acquisition Pin
gecool2-Dec-04 4:15
gecool2-Dec-04 4:15 
QuestionVisual Studio.net Project - Which folder(s) contain the actual project files that should be backed up?? Pin
jerry1211a2-Dec-04 4:09
jerry1211a2-Dec-04 4:09 
AnswerRe: Visual Studio.net Project - Which folder(s) contain the actual project files that should be backed up?? Pin
John R. Shaw2-Dec-04 5:05
John R. Shaw2-Dec-04 5:05 

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.