int main(){
	// I have an error in the next line
	read_file("F:/2nd year_2/Data structure 2/books/lecture-26.pdf");
	return 0;
}
string read_file(char* address){
	 string line;
	
  ifstream myfile (address);
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline (myfile,line);
      cout << line << endl;
    }
    myfile.close();
  }
	return NULL;
}

this program have an error and I think the problem is the file path
so how can I write it correctly

For starters, I would suggest never using spaces in a file name :)

If you insist on doing so, I think Windows likes backslashes instead of forward slashes - I don't if c++ cares about this.

Also, you may need to "escape" the space with a backslash:
read_file("F:/2nd\ year_2/Data structure 2/books/lecture-26.pdf");

I removed the spaces from the address and change the foreword slash with black slash (single and double) but I'm still having the same problem
and that's the error
identifier not found

Please include the entire compiler output. Which identifier is not found? My guess would be read_file, since you didn't declare it before main.

\\

yeah, you are right.
this error occurred because I declared a red_file method before the main method

Thanks

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.