Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

How can i set local variable to global variable in C++ ?

$
0
0
Hello guys,i created a config file and got line by line then parsed to variables.How can i set local (function) variable to global variable ? sorry for bad english. Current code: void GetSettings() { ifstream nameFileout; nameFileout.open("Settings.conf"); string line; if (!nameFileout.is_open()) { exit(0); } while (std::getline(nameFileout, line)) { string parse = "[Zoom]-10"; stringstream ss(parse); string temp = "[Zoom]"; getline(ss, temp, ']'); getline(ss, temp, '['); double Result; stringstream convert(temp); double Z2 = atof(temp.c_str()); AllocConsole(); freopen("CONOUT$", "w", stdout); std::cout << line << std::endl; } nameFileout.close(); } Output : Z2 = -10

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>