Code:
#include <stdio.h>
#include <iostream>
using namespace std;
int main ()
{
int i;
int x;
char str [80];
FILE * pFile;
FILE * pFile2;
FILE * pFile3;
//Writing to file
pFile = fopen ("aplus.txt","w+");
fprintf (pFile, "%s %d", "Y =",30);
printf ("%s %d\n",str,&i);
fclose (pFile);
system ("pause");
//Getting from file
pFile2 = fopen ("aplus.txt","r");
rewind (pFile2);
fscanf (pFile2, "%s", str);
fscanf (pFile2, "%d", i);
//Writing needed information to file
pFile3 = fopen ("aplus2.txt","w+");
fprintf (pFile3, "%d");
fclose (pFile2);
fclose (pFile3);
printf ("%d and %s \n",&i, str);
system("aplus.txt");
system("aplus2.txt");
return 0;
}
