-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_pm.cpp
More file actions
97 lines (75 loc) · 1.93 KB
/
json_pm.cpp
File metadata and controls
97 lines (75 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include<iostream>
#include<string>
#include<iomanip>
#include<string.h>
#include<fstream>
#define GET_VARIABLE_NAME(Variable) (#Variable)
using namespace std;
#define cont 1
#define stop 0
void maker(char Main[],string,string,int flag=cont);
void maker(char Main[],string,double,int flag=cont);
//double gives 6 floating point
int parser();
int main()
{
char Main[500];
string a[10];
double ram,cpu,io;
// string ram,cpu,io;
// int b=10;
// a[1]=to_string(b);
strcat(Main,"{ "); //Begening bracketter
// getline(cin,a[0]);
// maker(Main,GET_VARIABLE_NAME(a[0]),a[0],1);
//
// getline(cin,a[1]);
// maker(Main,GET_VARIABLE_NAME(a[1]),a[1],0);
cout<<"Ram: ";
cin>>ram;
maker(Main,GET_VARIABLE_NAME(ram),ram);
cout<<"CPU: ";
cin>>cpu;
maker(Main,GET_VARIABLE_NAME(cpu),cpu);
cout<<"IO: ";
cin>>io;
maker(Main,GET_VARIABLE_NAME(io),io,stop);
// strcat(Main,"\"a");
// strcat(Main,a[1].c_str());
// strcat(Main,"\" : \""); //Variable [0];
//
// getline(cin,a[0]);
// strcat(Main,a[0].c_str()); //Value [0];
// strcat(Main,"\"");
strcat(Main," }"); //End bracketter
// cout<<GET_VARIABLE_NAME(a[1])<<endl;
ofstream fout("JSON_txt.json");
fout<<Main<<endl;
fout.close();
parser();
return 0;
}
void maker(char Main[],string varName,string strval,int flag)
{
strcat(Main,"\"");
strcat(Main,varName.c_str());
strcat(Main,"\"");
strcat(Main," : ");
strcat(Main,"\"");
strcat(Main,strval.c_str());
strcat(Main,"\"");
if(flag==1)
strcat(Main,", ");
}
void maker(char Main[],string varName,double strval,int flag)
{
strcat(Main,"\"");
strcat(Main,varName.c_str());
strcat(Main,"\"");
strcat(Main," : ");
// strcat(Main,"\"");
strcat(Main,to_string(strval).c_str());
// strcat(Main,"\"");
if(flag==1)
strcat(Main,", ");
}