1

I am trying to read a file which is placed in the desktop through C++ program in linux server.I have mentioned the path correctly,but it's not reading the file. I have tried the same program in windows platform it's working fine.I'm able to read the file.

#include <stdio.h>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    string line;
    ifstream file;
    file.open("/home/xxx/Desktop/nodeinfo.txt",ios::in);
    if(!file.is_open())
    {
        cout<<"error";
    }
    getline(file,line);
    cout<<line;
    return 0;

}

could someone help me how to solve this problem. Is there any specific path format for linux platform. Thanks

Manimaran
  • 15
  • 2
  • 6
  • 2
    Possible duplicate of [How to get error message when ifstream open fails](http://stackoverflow.com/questions/17337602/how-to-get-error-message-when-ifstream-open-fails) – Andreas Fester Dec 02 '15 at 08:48
  • 1
    Do a `ls -l` to check file permissions and if it is a link. – Claudio Dec 02 '15 at 08:59

0 Answers0