Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 107,162 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,358 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Textfile into Listbox

 
Reply to this topicStart new topic

Textfile into Listbox, Windows Forms app

LaurieBi
post 6 Aug, 2008 - 02:01 PM
Post #1


New D.I.C Head

*
Joined: 13 Jun, 2008
Posts: 1

I know how to open and read/write using fstream objects, but what I want to do is use a windows forms app and a listbox - I want to read a text file into a listbox, but can't seem to make it work (at least not with fstream) can someone point me in the right direction please?


// reading small (12 items) textfile into an array
cpp
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
char buffer[2];
char person[12][20];
short j, loop, flag;

const int MAX = 12;

ifstream inPeople;
ofstream outFile;

// display
cout << "===========" << endl << " Available" << endl ;
cout << "===========" << endl;

// get the names into array
// first open file for input

inPeople.open("DSED.txt");
j = 0;
while ( ! inPeople.eof() )
{
inPeople.getline(person[j],20);
j++;
}

// close this file
inFile.close();


cin.getline(buffer,2);
return 0;
}

Mod edit: Please code.gif
Thanks, gabehabe smile.gif
User is offlineProfile CardPM

Go to the top of the page


jwwicks
post 7 Aug, 2008 - 10:42 PM
Post #2


D.I.C Head

Group Icon
Joined: 31 Jul, 2008
Posts: 51



Thanked 5 times

Dream Kudos: 200
My Contributions


Hello LaurieBi,

QUOTE(LaurieBi @ 6 Aug, 2008 - 02:01 PM) *

I know how to open and read/write using fstream objects, but what I want to do is use a windows forms app and a listbox - I want to read a text file into a listbox, but can't seem to make it work (at least not with fstream) can someone point me in the right direction please?



Umm you'll never get a listbox working in a Win32 Console App... Now depending on what your planning the code is different for MFC based applications versus Windows API versions versus .Net versions. And with .Net are we talking managed C++ or C#.

JW
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 8/27/08 09:20PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month