hi
i have a .txt file containg data like
__________________________________________________________________
Date Time ABC GD INo P mo SRD T
11/07/2010 9:24PM, 21.46 7.25,0000000025,0000001245,12000000,23.24
11/07/2010 9:34PM, 21.46 6.25,0000000025,0000001245,12000000,23.24
11/07/2010 9:44PM, 22.60 6.25,0000000025,0000001245,12000000,23.24
11/07/2010 9:54PM, 23.90 5.25,0000000025,0000001245,12000000,23.24
11/07/2010 10:04PM, 21.46 6.25,0000000025,0000001245,12000000,23.24
11/07/2010 10:14PM, 21.60 4.15,0000000025,0000001245,12000000,23.24
11/07/2010 10:24PM, 25.40 7.75,0000000025,0000001245,12000000,23.24
11/07/2010 10:34PM, 21.46 7.75,0000000025,0000001245,12000000,23.24
11/07/2010 10:44PM, 19.46 7.15,0000000025,0000001245,12000000,23.24
11/07/2010 10:54PM, 18.00 7.25,0000000025,0000001245,12000000,23.24
--------------------------------------------------------------------
now i need the data of three columns (i.e, ABC, GD and INO)for putting in to a string for output... What sort of program i should write?

You can do so using awk to print, e.g. fields 3,5,6:

awk '{print $3 " " $5 " " $6}' file.txt

This uses as separators whitespace, in any number or
succession. Otherwise, you can specify the separator with option
-F. If you have complex separators, -F takes aregular expression
as argument. For example, if you have space and comma as
separators (any number or sequence), use

awk -F "[ ,]+" '{print $3 " " $5 " " $6}' file.txt
(separator is at least one of the characters between []).

If you have fixed width fields, you can read line by line, then:
1) in C, use strncpy to copy the substring in another variable;
2) in C++, if the line is in a String, use the member function substr()

commented: This is the C++ forum, not the AWK or C forum. Please understand where you are before posting. -3

What sort of program i should write?

How about a C++ program that reads a line, pulls out the data you want, and outputs that data?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.