[Solved] How can I store a variable in another file?


You can use std::fstream:

#include <fstream>
#include <iostream>

int myint;

int main() {
    // when entering app:
    std::ifstream fs("data.txt");
    if ( fs ) {
        fs >> myint;
    }
    fs.close();

    std::cout << myint;
    myint++;

    // when exiting app:
    std::ofstream fs2("data.txt");
    fs2 << myint;
}

2

solved How can I store a variable in another file?