Click here to Skip to main content
15,893,644 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Simple C to C++ Pin
Chris Losinger14-Sep-11 10:16
professionalChris Losinger14-Sep-11 10:16 
GeneralRe: Simple C to C++ [modified] Pin
Software200714-Sep-11 10:21
Software200714-Sep-11 10:21 
GeneralRe: Simple C to C++ Pin
Chris Losinger14-Sep-11 10:38
professionalChris Losinger14-Sep-11 10:38 
GeneralRe: Simple C to C++ Pin
Chuck O'Toole14-Sep-11 14:54
Chuck O'Toole14-Sep-11 14:54 
GeneralRe: Simple C to C++ Pin
Chuck O'Toole14-Sep-11 14:13
Chuck O'Toole14-Sep-11 14:13 
AnswerRe: Simple C to C++ Pin
Chuck O'Toole14-Sep-11 14:08
Chuck O'Toole14-Sep-11 14:08 
AnswerRe: Simple C to C++ Pin
Chuck O'Toole14-Sep-11 14:32
Chuck O'Toole14-Sep-11 14:32 
AnswerRe: Simple C to C++ Pin
enhzflep14-Sep-11 16:21
enhzflep14-Sep-11 16:21 
The reason there's no upper limit on "i" in either of the for loops is that this would take more code - it would require a strlen be performed once before the loop in addition to checking to see if i is equal to this length. It's less clear to read and more prone to induce error during maintenance, but I believe it to be for this reason that the way the loop is exited with a break.

Not sure why you'd go the trouble of #defining NUL as 0x0.. It would be clearer if the already provided NULL was used (less code too, since there's only 4 references to 'NUL' - 4 cases of simply adding another 'L'. In any case, the executable code is identical - it is just the source-code that suffers from reduced readability, unlike the loop-terminating-condition check, which produces a smaller executable when done this way than the more readable alternative of checking the strlen first then using a terminarting condition of i<strlen(

can't see="" any="" reason="" for="" this="" to="" crash="" when="" executing="" the="" 'msg[i]="NUL'" statement,="" unless="" you're="" trying="" pass="" a="" string="" constant,="" rather="" than="" dynamically="" loaded="" created="" string.="" example,="" i="" can="" failing
<pre="">char *htmlStr = "<html>";
replace_html_delimiters(htmlStr);

while I can see this succeeding
char *htmlStr = "<html>";
char htmlStrCopy = strdup(htmlStr);
replace_html_delimiters(htmlStrCopy);
..
.. other actions on htmlStrCopy
..
free(htmlStrCopy);



Add to that the fact that the "char z_buf[4095]" statement isn't terminated with a ';' in either case and you have rather a problem, considering that the C function called with a string containing "" returns the same string. Studying the function, it appears to scan through a string, quitting upon end of string (0x0), while perplexingly, when it intercepts a '<' character it copies all of the text except for this character, then it appends the '<' explicitly. It's 5am here, and I can't think of a circumstance that the output sring would be different to the input string.
GeneralRe: Simple C to C++ Pin
Chuck O'Toole14-Sep-11 17:18
Chuck O'Toole14-Sep-11 17:18 
AnswerRe: Simple C to C++ Pin
Erudite_Eric14-Sep-11 20:41
Erudite_Eric14-Sep-11 20:41 
AnswerRe: Simple C to C++ Pin
Richard MacCutchan14-Sep-11 22:14
mveRichard MacCutchan14-Sep-11 22:14 
GeneralRe: Simple C to C++ Pin
Orjan Westin15-Sep-11 1:38
professionalOrjan Westin15-Sep-11 1:38 
GeneralRe: Simple C to C++ Pin
Richard MacCutchan15-Sep-11 1:43
mveRichard MacCutchan15-Sep-11 1:43 
AnswerRe: Simple C to C++ Pin
Orjan Westin15-Sep-11 1:32
professionalOrjan Westin15-Sep-11 1:32 
AnswerRe: Simple C to C++ Pin
Stefan_Lang15-Sep-11 1:43
Stefan_Lang15-Sep-11 1:43 
GeneralRe: Simple C to C++ Pin
Richard MacCutchan15-Sep-11 1:47
mveRichard MacCutchan15-Sep-11 1:47 
JokeRe: Simple C to C++ Pin
MicroVirus15-Sep-11 3:36
MicroVirus15-Sep-11 3:36 
QuestionMFC OpenGL Invalidate Flickering Pin
appollosputnik14-Sep-11 6:19
appollosputnik14-Sep-11 6:19 
AnswerRe: Flicker Free Drawing In MFC Pin
Software_Developer14-Sep-11 7:32
Software_Developer14-Sep-11 7:32 
AnswerRe: MFC OpenGL Invalidate Flickering Pin
Roger Allen27-Sep-11 6:23
Roger Allen27-Sep-11 6:23 
QuestionShowHTMLDialog not working in Windows 7 Pin
doug2514-Sep-11 4:00
doug2514-Sep-11 4:00 
AnswerRe: ShowHTMLDialog not working in Windows 7 Pin
Chris Meech14-Sep-11 6:07
Chris Meech14-Sep-11 6:07 
GeneralRe: ShowHTMLDialog not working in Windows 7 Pin
doug2514-Sep-11 7:39
doug2514-Sep-11 7:39 
GeneralRe: ShowHTMLDialog not working in Windows 7 Pin
Chris Meech14-Sep-11 8:27
Chris Meech14-Sep-11 8:27 
GeneralRe: ShowHTMLDialog not working in Windows 7 Pin
doug2514-Sep-11 8:59
doug2514-Sep-11 8:59 

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.