Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

file handling in c++

+1 vote
asked Oct 14, 2018 by NaveedAsif (150 points)
sir i have saved my file in D derive and i referenced it in code but after compilation following error has been occured. file could not open. code is given below.

#include<iostream>
#include<fstream>
using namespace std;
int main(){
    char name[100];// used to read name of employee from file
    char sal [100];// used to read name of employee from file
    char dep[100];// used to read name of employee from file
    ifstream inFile;
    char inputFileName[]="D:\naveed/ali.txt";
    inFile.open(inputFileName);
    //checking the file is opened or not
    if(!inFile){
        cout<<"cannot open input file"<<"\t"<<inputFileName;
        exit(1);
    }
    while(!inFile.eof()){
        inFile>>name>>sal>>dep;
        cout<<name<<"\t"<<sal<<"\t"<<dep;
    }
    inFile.close();
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...