Click here to Skip to main content
15,918,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: bizarre problem with files Pin
lahom23-Jun-08 6:10
lahom23-Jun-08 6:10 
GeneralRe: bizarre problem with files Pin
CPallini23-Jun-08 6:42
mveCPallini23-Jun-08 6:42 
GeneralRe: bizarre problem with files Pin
lahom25-Jun-08 6:55
lahom25-Jun-08 6:55 
QuestionRe: bizarre problem with files Pin
CPallini25-Jun-08 11:07
mveCPallini25-Jun-08 11:07 
AnswerRe: bizarre problem with files Pin
lahom25-Jun-08 12:25
lahom25-Jun-08 12:25 
GeneralRe: bizarre problem with files Pin
CPallini25-Jun-08 21:00
mveCPallini25-Jun-08 21:00 
AnswerRe: bizarre problem with files Pin
Kwanalouie23-Jun-08 1:47
Kwanalouie23-Jun-08 1:47 
AnswerRe: bizarre problem with files [modified] Pin
Kwanalouie24-Jun-08 0:24
Kwanalouie24-Jun-08 0:24 
One problem your code has is in the method you are opening the files with fopen. There are two modes for reading and writing to files - binary mode and text mode. Some character conversions change in those two modes. When you open file1 and file2 you do not specify what mode to use, so the default mode is used. When you open m_sFileName you tell it to open it to read in binary mode instead of text mode.

Try changing the "w" to "wt" in this statement of yours
FILE *file1 = fopen("file1.txt","w");

And more importantly change the "rb" to "rt" since you are trying to read characters in the following statement in your code
fp=fopen(m_sFileName,"rb"); //Open file for reading

The ftell and fseek functions may not give the correct lengths if the file is opened in text mode, however. So you should simplify things and use the fgets() function to get the string you want.

Since you are working with text files they should be opened with the text attribute.

modified on Tuesday, June 24, 2008 6:30 AM

Questionthere is a questioin about function pointer and template Pin
CresShadow22-Jun-08 16:18
CresShadow22-Jun-08 16:18 
AnswerRe: there is a questioin about function pointer and template Pin
Saurabh.Garg22-Jun-08 17:31
Saurabh.Garg22-Jun-08 17:31 
QuestionVisual Studio: Where do I put my stuff? Pin
bkelly1322-Jun-08 16:06
bkelly1322-Jun-08 16:06 
AnswerRe: Visual Studio: Where do I put my stuff? Pin
Saurabh.Garg22-Jun-08 17:39
Saurabh.Garg22-Jun-08 17:39 
QuestionIs it safe to call GetPrivateProfileString in Serialize? Pin
followait22-Jun-08 14:04
followait22-Jun-08 14:04 
AnswerRe: Is it safe to call GetPrivateProfileString in Serialize? Pin
led mike22-Jun-08 14:49
led mike22-Jun-08 14:49 
GeneralRe: Is it safe to call GetPrivateProfileString in Serialize? Pin
followait22-Jun-08 15:26
followait22-Jun-08 15:26 
QuestionHow to SHow all files and sub-directories and there all files By usign c++ Only c++ Pin
Pak_Coder22-Jun-08 7:37
Pak_Coder22-Jun-08 7:37 
AnswerRe: How to SHow all files and sub-directories and there all files By usign c++ Only c++ Pin
Robert.C.Cartaino22-Jun-08 7:53
Robert.C.Cartaino22-Jun-08 7:53 
GeneralRe: How to SHow all files and sub-directories and there all files By usign c++ Only c++ Pin
Pak_Coder22-Jun-08 13:31
Pak_Coder22-Jun-08 13:31 
GeneralRe: How to SHow all files and sub-directories and there all files By usign c++ Only c++ Pin
Stephen Hewitt22-Jun-08 15:49
Stephen Hewitt22-Jun-08 15:49 
Questionhow to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
Pak_Coder22-Jun-08 5:30
Pak_Coder22-Jun-08 5:30 
AnswerRe: how to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
Saurabh.Garg22-Jun-08 5:38
Saurabh.Garg22-Jun-08 5:38 
GeneralRe: how to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
Pak_Coder22-Jun-08 5:41
Pak_Coder22-Jun-08 5:41 
GeneralRe: how to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
zafersavas22-Jun-08 6:03
zafersavas22-Jun-08 6:03 
GeneralRe: how to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
Pak_Coder22-Jun-08 6:07
Pak_Coder22-Jun-08 6:07 
GeneralRe: how to resolve this problem fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' Pin
Saurabh.Garg22-Jun-08 14:25
Saurabh.Garg22-Jun-08 14:25 

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.