#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main()
{
    //system("clear");
    cout<<"\npls input the file where you want to read the data from\n";
    string loc;
    getline(cin,loc);
    ifstream g;
    g.open (loc.c_str(),ios::in);
    string data;
    g>>data;
    cout<<"\n\n\n\n";
    cout<<"\nthe data read from the file is\n";
    cout<<endl<<data;
    return 0;
}

even if fiole being read contains a full line of entries(separated by say spaces) then too output is the first word only....??

Input using the >> operator is delimited by whitespace, so by default you'll only read the next "word" in the stream. If you want a full line, use getline().

Here's a quick example:

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main(){
    string filename;
    ifstream fin(filename.c_str(), ios::in);
    if (fin.is_open()){
        string line;
        while (getline(fin, line)){
            cout<<line;
        }
    }
    else cout<<"Invaild file.";
    return (0);
}

Getline will take the input from the file either till '\n' appears or the EOF (end of file).
So, you put it in a while loop, and you get the output.
You can add delimiters, but here's not the case.
Here's a usefull link about getline.

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.