Click here to Skip to main content
15,844,602 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: file not recognized: File format not recognized Pin
Vaclav_29-Jan-20 16:39
Vaclav_29-Jan-20 16:39 
Questionreplace words in a file Pin
Member 1295754729-Jan-20 5:19
Member 1295754729-Jan-20 5:19 
AnswerRe: replace words in a file Pin
Victor Nijegorodov29-Jan-20 6:30
Victor Nijegorodov29-Jan-20 6:30 
GeneralRe: replace words in a file Pin
Member 1295754729-Jan-20 6:34
Member 1295754729-Jan-20 6:34 
GeneralRe: replace words in a file Pin
k505429-Jan-20 6:52
mvek505429-Jan-20 6:52 
AnswerRe: replace words in a file Pin
k505429-Jan-20 6:42
mvek505429-Jan-20 6:42 
SuggestionRe: replace words in a file Pin
David Crow29-Jan-20 18:04
David Crow29-Jan-20 18:04 
AnswerRe: replace words in a file Pin
Stefan_Lang29-Jan-20 22:21
Stefan_Lang29-Jan-20 22:21 
A couple of things I've noticed:

1. You are always using 'file1.txt' in your code, not the filename(s) passed as argument
2. As has been pointed out, lines can be longer than 1000 chars.
3. You never close the file you've opened. That will cause changes in one file buffer to overwrite previous changes once the files are closed (or at the end of the program).
4. You only check for one occurence of a word per line. What if there are multiple occurrences?

Suggestions:
- As already pointed out, start with your replace functions and make sure they work as intended, before dealing with files!
- Make sure you always close the files you've opened
- Write the modified text into another, temporary file. Later erase the original file, and rename the temporary one. That way you can just keep on reading/writing without needing to close/open the file over and over again.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

QuestionLinking libraries - follow-up- gcc++ won't link Pin
Vaclav_28-Jan-20 5:22
Vaclav_28-Jan-20 5:22 
AnswerRe: Linking libraries - follow-up- gcc++ won't link Pin
Richard MacCutchan28-Jan-20 6:04
mveRichard MacCutchan28-Jan-20 6:04 
AnswerRe: Linking libraries - follow-up- gcc++ won't link Pin
k505428-Jan-20 6:08
mvek505428-Jan-20 6:08 
AnswerRe: Linking libraries - follow-up- gcc++ won't link Pin
CPallini28-Jan-20 6:13
mveCPallini28-Jan-20 6:13 
GeneralRe: Linking libraries - follow-up- gcc++ won't link Pin
k505428-Jan-20 7:47
mvek505428-Jan-20 7:47 
GeneralRe: Linking libraries - follow-up- gcc++ won't link Pin
CPallini28-Jan-20 10:52
mveCPallini28-Jan-20 10:52 
AnswerRe: Linking libraries - follow-up- gcc++ won't link Pin
Vaclav_28-Jan-20 8:07
Vaclav_28-Jan-20 8:07 
GeneralRe: Linking libraries - follow-up- gcc++ won't link Pin
Richard MacCutchan28-Jan-20 10:22
mveRichard MacCutchan28-Jan-20 10:22 
AnswerSOLVED (?) Re: Linking libraries - follow-up- gcc++ won't link Pin
Vaclav_29-Jan-20 5:00
Vaclav_29-Jan-20 5:00 
GeneralRe: SOLVED (?) Re: Linking libraries - follow-up- gcc++ won't link Pin
Richard MacCutchan29-Jan-20 5:16
mveRichard MacCutchan29-Jan-20 5:16 
QuestionReverse engineering GCC output - need library file (name) and path. Pin
Vaclav_27-Jan-20 6:34
Vaclav_27-Jan-20 6:34 
AnswerRe: Reverse engineering GCC output - need library file (name) and path. Pin
Gerry Schmitz27-Jan-20 6:55
mveGerry Schmitz27-Jan-20 6:55 
GeneralRe: Reverse engineering GCC output - need library file (name) and path. Pin
Vaclav_28-Jan-20 3:44
Vaclav_28-Jan-20 3:44 
AnswerRe: Reverse engineering GCC output - need library file (name) and path. Pin
Richard MacCutchan27-Jan-20 7:09
mveRichard MacCutchan27-Jan-20 7:09 
AnswerRe: Reverse engineering GCC output - need library file (name) and path. Pin
k505427-Jan-20 7:24
mvek505427-Jan-20 7:24 
GeneralRe: Reverse engineering GCC output - need library file (name) and path. Pin
Vaclav_27-Jan-20 8:00
Vaclav_27-Jan-20 8:00 
AnswerRe: Reverse engineering GCC output - need library file (name) and path. Pin
leon de boer27-Jan-20 23:28
leon de boer27-Jan-20 23: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.