currently i am making GUI for my program. for this i need to read No. or integer or string (single word) from text file. I am using visual studio 2005 c++ CLI windows form application.
for reading text file i use streamreader.
there is an option for reading whole line(using readline) or whole file(using read to end).
can anyone tell me how to read specific no. or integer from each line of whole text file?
Thanking you in anticipation.
Loading
Sam HobbsPosted Nov 25, 2009, 10:43 AM
Jignesh PatelPosted Nov 24, 2009, 1:06 PM
Sam HobbsPosted Nov 23, 2009, 11:18 PM
I am still not sure what you need but I hope the following is close enough. This will process the third column of each record. It is a Console program but the code can be used in a form application also. You can use the console program to test the code if that is convenient.
Jignesh PatelPosted Nov 22, 2009, 10:45 PM
my data is as per following
xyz data
3 2 4 3 2
Sr. No. name x1 x2 x3 ....
1 abc 13 42 53....
2 xaz 42 32 43....
and so on
now from this data i have to read column viz. 13, 42 etc
also i have to read specific no like 3 and 4 from second line
i use visual studio 2005 cpp windows form application
Sam HobbsPosted Nov 22, 2009, 6:48 PM
It is very frustrating for me when I answer a question and then the person says my answer is wrong and then the person I am trying to help tells me something they should have told me originally. If I post sample code that does what I understand you need, then please don't tell me it is wrong if there is something you did not tell me about what you need.
Jignesh PatelPosted Nov 22, 2009, 8:10 AM
Jignesh PatelPosted Nov 22, 2009, 8:05 AM
Sam HobbsPosted Nov 21, 2009, 5:36 PM
Kirtan PatelPosted Nov 21, 2009, 1:04 PM
villiPosted Nov 21, 2009, 1:02 PM
class class1{
static void main(string[] args)
{
streamreader sr =new streamreader("filename.txt");
console.writeline(sr.readtoend());
sr.close();
}
}
To Line by Line file Reading:->
S=new filestream("filename.txt",filemode.open);
streamreader r= new streamreader(s);
string t;
while((t=r.readline()) != null)
{
console.writeline(t);
}
try this code:->
If i cant understand your problem then sorry, i m just try to help u, ok
otherwise this code is helpful to u.