Like the title, I'm having some problems with my codes. It seems like the program doesn't stop. I think the problem is c++ couldn't read .json file because I've tested with text file, the program didn't make error, then I test with unexist file and the program loop like when I test with .json file. So I think c++ couldn't read unexist file and seem like .json have the same problem. Please help me. I just begin learnning c++ so if you can solve problem, I hope you can show me why my code is wrong and recommend the solutions. Here my code
#include <iostream>
#include <fstream>
#include<string>
using namespace std;
void main()
{
fstream file;
char a[80], b;
string c;
file.open("D://New folder//testcase//Project3//conf.json",ios::in );
while (!file.eof())
{
file.getline(a, 80);
cout << a << "\n";
}
if (file.fail()) cout << "Abc";
file.close();
cin >> b;
}
Here's my configuration file
{
"name": "PF182-A01",
"version": "1.0.0",
"author": "Duc Dung Nguyen",
"email": "nddung (at) hcmut.edu.vn",
"WelcomeText": {
"line1": "******************************************************************************",
"line2": "* Welcome to CSE-HealthCare System *",
"line3": "* This is a simple application designed for the first assignment of PF *",
"line4": "* course (CO1011, Semester 182). The student must demonstrate the ability to *",
"line5": "* write a program for a given problem. The student need to analyze the *",
"line6": "* requirements of the problem before implementing the application. *",
"line7": "******************************************************************************",
"line8": "Email: nddung@hcmut.edu.vn",
"line9": "(c) 2019 Duc Dung Nguyen All Rights Reserved."
},
"Menu": {
"opt1": "Introduction",
"opt2": "Login",
"opt3": "Registration",
"opt4": "Help",
"opt5": "Exit"
},
"IntroTime": 3,
}