Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionread text filememberpeoria1237 Dec '12 - 9:59 
I want to read text file into edit boxses
e.g 10 string present in a text file. I have 10 edit boxes on dialog. how i can read that 10 string into edit box?
 
Thanks.
AnswerRe: read text file PinmemberAndré Kraak7 Dec '12 - 20:56 
You can use the std::getline[^] for reading lines from a file.
Input/Output with files[^] explains how to work with files.
0100000101101110011001000111001011101001

AnswerRe: read text file Pinmembersajeesh.c9 Dec '12 - 21:05 
I think first you should add a button in dialog and on handle of this button write the code below
void CReadFileDlg::OnReadFile() 
{
    CEdit* m_EditArray[10];
    CStringArray FileArray;
    char cTemp[256];
    ifstream fin;
    fin.open( _T("C:\\FileRead.txt"), ios::in|ios::nocreate );
    while( !fin.eof() )
    {
        // The getline function is used to read an entire line
        fin.getline( cTemp, 256, '\n' );
        CString csChartoString;
        csChartoString.Format( "%s", cTemp );
        if( csChartoString != "" )
        {
            FileArray.Add( csChartoString );
        }
     }
    int top = 10;
    int bottom = 30;
    for(int i = 0; i < 10; i++)
    {
        m_EditArray[i] = new CEdit;
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
        m_EditArray[i]->Create(dwStyle, CRect(10,top,100,bottom), this,100+i);
        m_EditArray[i]->ShowWindow(TRUE);
        top += 30;
        bottom += 30;
    }
    int nArraySize = FileArray.GetSize();
    int nPos = 0;
    for( int nIdx= 0; nIdx < nArraySize; ++nIdx )
    {
        m_EditArray[nIdx]->SetWindowText( FileArray.GetAt( nIdx ));
    }
}

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 22 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid