Click here to Skip to main content
15,902,634 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
Hamid_RT10-Feb-08 21:38
Hamid_RT10-Feb-08 21:38 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
ShilpiP7-Feb-08 22:41
ShilpiP7-Feb-08 22:41 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
Rajesh R Subramanian7-Feb-08 23:22
professionalRajesh R Subramanian7-Feb-08 23:22 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
ShilpiP7-Feb-08 23:53
ShilpiP7-Feb-08 23:53 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
David Crow8-Feb-08 3:01
David Crow8-Feb-08 3:01 
GeneralRe: PLZ suggest me!!!!!!!!! Pin
Hamid_RT10-Feb-08 21:36
Hamid_RT10-Feb-08 21:36 
Generalwrite to one file in a loop, each iteration writes a column beside the previous column. Pin
mrby1237-Feb-08 18:29
mrby1237-Feb-08 18:29 
GeneralRe: write to one file in a loop, each iteration writes a column beside the previous column. Pin
Rajesh R Subramanian7-Feb-08 19:54
professionalRajesh R Subramanian7-Feb-08 19:54 
See if this helps:
CStdioFile csf;
CFileException cfe;
CString str, sTemp;
CStringArray csa, csa2;
int iSize=0;

int n=3;

//Create a CStringArray which would hold the new column to be added
for(int i=1; i<=n; ++i)
{
    sTemp.Format(_T(" (%d,%d)"),i,n);
    csa2.Add(sTemp);
    //AfxMessageBox(sTemp);
}

if ( !csf.Open(_T("E:\\Some.txt"), CFile::modeReadWrite, &cfe) )
{
    AfxMessageBox(_T("Failed to open the file"));
    return;
}

int iLoop = 0;
while(csf.ReadString(str))
{
    str.Format(_T("%s%s"),str, csa2.GetAt(iLoop));//Read each and every line in the file
    csa.Add(str);//and append the new column to each line
    ++iLoop;//loop through each line
}

csf.SeekToBegin();
iSize = csa.GetSize();

for(int j=1; j<=iSize; ++j)
{
    sTemp.Format(_T("%s\n"), csa.GetAt(j-1));
    csf.WriteString(sTemp);//Finally write it to the file
}
csf.Close();



Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP

GeneralRe: write to one file in a loop, each iteration writes a column beside the previous column. Pin
mrby1238-Feb-08 8:22
mrby1238-Feb-08 8:22 
GeneralRe: write to one file in a loop, each iteration writes a column beside the previous column. [modified] Pin
mrby12311-Feb-08 9:58
mrby12311-Feb-08 9:58 
GeneralRe: write to one file in a loop, each iteration writes a column beside the previous column. Pin
Rajesh R Subramanian11-Feb-08 21:34
professionalRajesh R Subramanian11-Feb-08 21:34 
GeneralRe: write to one file in a loop, each iteration writes a column beside the previous column. Pin
mrby12312-Feb-08 5:50
mrby12312-Feb-08 5:50 
GeneralExe or a service Pin
Manasi D7-Feb-08 17:58
Manasi D7-Feb-08 17:58 
GeneralRe: Exe or a service Pin
Rajkumar R8-Feb-08 0:06
Rajkumar R8-Feb-08 0:06 
GeneralLPT I/O Port Access in Vista [modified] Pin
x87Bliss7-Feb-08 14:44
x87Bliss7-Feb-08 14:44 
GeneralRe: LPT I/O Port Access in Vista Pin
Stephen Hewitt7-Feb-08 15:56
Stephen Hewitt7-Feb-08 15:56 
GeneralRe: LPT I/O Port Access in Vista Pin
Rajkumar R7-Feb-08 18:29
Rajkumar R7-Feb-08 18:29 
GeneralRe: LPT I/O Port Access in Vista Pin
Stephen Hewitt7-Feb-08 18:45
Stephen Hewitt7-Feb-08 18:45 
GeneralRe: LPT I/O Port Access in Vista Pin
Rajkumar R7-Feb-08 19:04
Rajkumar R7-Feb-08 19:04 
GeneralRe: LPT I/O Port Access in Vista Pin
Stephen Hewitt7-Feb-08 19:07
Stephen Hewitt7-Feb-08 19:07 
GeneralRe: LPT I/O Port Access in Vista Pin
jhwurmbach7-Feb-08 21:26
jhwurmbach7-Feb-08 21:26 
GeneralRe: LPT I/O Port Access in Vista Pin
Stephen Hewitt9-Feb-08 2:31
Stephen Hewitt9-Feb-08 2:31 
GeneralRe: LPT I/O Port Access in Vista Pin
Rajkumar R7-Feb-08 23:08
Rajkumar R7-Feb-08 23:08 
GeneralRe: LPT I/O Port Access in Vista Pin
x87Bliss8-Feb-08 5:46
x87Bliss8-Feb-08 5:46 
GeneralRe: LPT I/O Port Access in Vista Pin
Stephen Hewitt7-Feb-08 18:45
Stephen Hewitt7-Feb-08 18:45 

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.