My code looks like this:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
    FILE* file;
    file = fopen("file.txt", "w+");
    char *tab;
    char *tab2;
    cout << "Input: " << endl;
    cin >> tab;
    fprintf(file, "%s", tab);
    rewind(file);
    fscanf(file, "%s", tab2);
    printf("%s", tab2);
    fclose(file);
}
So saving to file is working, but while I want to read from file to *tab2 it doesn't work and program instantly crashes. Any help with this?
 
     
    