Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to input a file path in c++

int main()
{
    std::cout << "Please enter the file name: ";
    std::string name;
    std::getline (std::cin, name);
    ifstream ifs(name.c_str());
    if (!ifs) error("can't open input file ", name);

    vector < Point > points;
    Point p;
    while (ifs >> p) points.push_back(p);
    // ....
}
 
PREVIOUS NEXT
Tagged: #input #file #path
ADD COMMENT
Topic
Name
7+6 =