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

villi2 reputationPosted Nov 21, 2009, 8:02 AM EST
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.
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 21, 2009, 8:04 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Nov 21, 2009, 12:36 PM EST
Jignesh Patel9 reputationPosted Nov 22, 2009, 3:05 AM EST
Jignesh Patel9 reputationPosted Nov 22, 2009, 3:10 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Nov 22, 2009, 1:48 PM EST
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 Patel9 reputationPosted Nov 22, 2009, 5:45 PM EST
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 HobbsRank #107 · 20.5K reputationPosted Nov 23, 2009, 6:18 PM EST
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 Patel9 reputationPosted Nov 24, 2009, 8:06 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Nov 25, 2009, 5:43 AM EST