lundi 19 février 2018

read the first line of file using c++

#include<stdio.h>
#include<iostream>
#include<dirent.h>
#include<fstream>
using namespace std;
int main()
{
  ifstream infile;
  string str;
  str="path"; 
  infile.open(str);
  if(infile.is_open())
    {
     string sline;
     getline(infile, sline);
     cout<<sline;
     }
}

*/i run this code & it is showing an error like no matching function call for infile.open. tell me where i am wrong & tell me how can i pass a str to infile.open that contains the path of the file that i want to open/*

Aucun commentaire:

Enregistrer un commentaire