where to mention the line i want from txt file...

i want the user to provide detail about the line and the program to provide the total line please help . i have tried many things but it shows some part or whole of the file...
Not sure if I understand your question but here is code to print a specific line in a text file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>
#include <fstream>
#include <limits>

int main()
{
	std::ifstream in("filename");
	
	int lineNumber;
	
	std::cout << "What line number do you want to show? ";
	std::cin >> lineNumber;
	
	for (int i = 0; i < lineNumber; i++)
	{
		in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
	}
	
	std::string line;
	std::getline(in, line);
	
	std::cout << "Line " << lineNumber << ": " << line << std::endl;
}
thanks peter87 actually i wanted the user to give some information about the line....
+ it says numeric_limits is not a member of std :\
Did you include <limits>?
Topic archived. No new replies allowed.