hello everyone!
i have a question about reading from a binary file.what if i want to start reading a file from a certain line of the file and end the reading to a certain line too?
is there a way to do this using an ifstream?

Sure.
Read the file until you get to the 'certain start line'.
Then continue reading and doing what you need to do with each line.
When you reach the 'certain end line', stop reading.

thanks for your help
so i tried something like this
but i'm still not sure i got the whole idea:

long from = atoi(argv[2]); //argv[2] is the line number i want to begin //reading the file
	long to = atoi(argv[3]); //argv[3] is the line number i want to stop
	ifstream fp;
	streampos pos,finalpos;
	char line[LINESIZE];
	fp.open (argv[1]); //argv[1] is the name of the file
	if (!fp.is_open())
		throw "File not found ";
	pos = from;
	finalpos = to;
	fp.seekg(pos); 
	while(fp.tellg()!=finalpos){
		try{
			fp.getline(line,LINESIZE);		
			
			}
		catch(char d[LINESIZE]){
			cout<<d<<endl;
		}

does this seem ok?i'm a bit confused..

does this seem ok?i'm a bit confused..

Not at all. Use my technique. It's simple. tkud's solution needs a lot more understanding of files than you have at this point in your programming.

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.