Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: printf without stdio.h Pin
Mircea Neacsu5-Dec-23 16:42
Mircea Neacsu5-Dec-23 16:42 
AnswerRe: printf without stdio.h Pin
Victor Nijegorodov5-Dec-23 5:32
Victor Nijegorodov5-Dec-23 5:32 
AnswerRe: printf without stdio.h Pin
k50545-Dec-23 6:02
mvek50545-Dec-23 6:02 
GeneralRe: printf without stdio.h Pin
jschell6-Dec-23 7:07
jschell6-Dec-23 7:07 
Questioncopying a file Pin
mike74115-Dec-23 3:24
mike74115-Dec-23 3:24 
AnswerRe: copying a file Pin
Mircea Neacsu5-Dec-23 3:32
Mircea Neacsu5-Dec-23 3:32 
AnswerRe: copying a file Pin
Richard MacCutchan5-Dec-23 4:05
mveRichard MacCutchan5-Dec-23 4:05 
AnswerRe: copying a file Pin
k50545-Dec-23 4:42
mvek50545-Dec-23 4:42 
While your method may work, assuming that ch is an int, and so does not have the 255/-1 issue, your method is horribly inefficient. Richard's suggestion to use fread/fwrite produces much better performance.

For example, given an 8M file, looping through your code 100 times took about 32 seconds. Using a fread/fwrite using a 4K buffer, the same 100 lops took just under 1 second to complete. This was on a PI-3, and successive runs remained stable. I'd expect an 8M file to sit comfortably in the file cache, so the difference is totally down to the difference between extracting a single char at a time, and reading a lot of characters at a time.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown

QuestionMyth of a Myth? Pin
jschell4-Dec-23 3:38
jschell4-Dec-23 3:38 
AnswerRe: Myth of a Myth? Pin
Richard MacCutchan4-Dec-23 4:57
mveRichard MacCutchan4-Dec-23 4:57 
AnswerRe: Myth of a Myth? Pin
Mircea Neacsu4-Dec-23 5:05
Mircea Neacsu4-Dec-23 5:05 
GeneralRe: Myth of a Myth? Pin
harold aptroot6-Dec-23 19:55
harold aptroot6-Dec-23 19:55 
Questionhow to add another primary menu - C + in Qt Pin
Salvatore Terress1-Dec-23 6:34
Salvatore Terress1-Dec-23 6:34 
AnswerRe: how to add another primary menu - C + in Qt Pin
Andre Oosthuizen1-Dec-23 22:18
mveAndre Oosthuizen1-Dec-23 22:18 
GeneralRe: how to add another primary menu - C + in Qt Pin
Richard MacCutchan1-Dec-23 22:22
mveRichard MacCutchan1-Dec-23 22:22 
QuestionInvalidate rectangle Pin
Calin Negru1-Dec-23 0:41
Calin Negru1-Dec-23 0:41 
AnswerRe: Invalidate rectangle Pin
CPallini1-Dec-23 1:01
mveCPallini1-Dec-23 1:01 
GeneralRe: Invalidate rectangle Pin
Calin Negru1-Dec-23 1:40
Calin Negru1-Dec-23 1:40 
GeneralRe: Invalidate rectangle Pin
CPallini1-Dec-23 1:56
mveCPallini1-Dec-23 1:56 
AnswerRe: Invalidate rectangle Pin
Richard MacCutchan1-Dec-23 2:13
mveRichard MacCutchan1-Dec-23 2:13 
GeneralRe: Invalidate rectangle Pin
Calin Negru1-Dec-23 3:55
Calin Negru1-Dec-23 3:55 
GeneralRe: Invalidate rectangle Pin
Richard MacCutchan1-Dec-23 4:28
mveRichard MacCutchan1-Dec-23 4:28 
GeneralRe: Invalidate rectangle Pin
Calin Negru2-Dec-23 5:02
Calin Negru2-Dec-23 5:02 
GeneralRe: Invalidate rectangle Pin
Richard MacCutchan2-Dec-23 6:47
mveRichard MacCutchan2-Dec-23 6:47 
AnswerRe: Invalidate rectangle Pin
charlieg7-Dec-23 1:24
charlieg7-Dec-23 1:24 

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.