Promoting The User To Enter A File Name

Hi there. I'm need to C++ so I hope everything is right so far. I basically need help promoting the user for a file name and opening the file name. I don't know how to do that.

1
2
3
4
5
6
7
8
9
  
#include <iostream>
#include <fstream>
#include <string>
  using namespace std;
    int main()
   {
   cout << "Hi there. Please enter a file name."
                                                                                                                                                                                                                                                          


Here is the list of what I have to do. I need help with the first and second lines of the list.



Read file name (string name) and (int k)
Open file F = open(name)
Open stream S(F), int i = 1, Init Tree T
while(i<=k)
read S from k = 0 to k == end
read i characters char* chars
T.add(chars)
k+=i
i++
closed account (E0p9LyTq)
http://www.cplusplus.com/reference/string/string/getline/
http://www.cplusplus.com/reference/fstream/fstream/open/
What does open file f mean?
What does open file f mean?

In everyday language, compare it with opening a book. You need to open a book before you can read (or write) anything.

In computing, it means making a connection between your program and a real file somewhere, usually on the computer's hard drive. This allows the program to access the contents of the file.

See the tutorial.
http://www.cplusplus.com/doc/tutorial/files/
Topic archived. No new replies allowed.