So im writing c++ program, that takes a integer from input file, multiply it with 2 and outputs it on output file. So the code is -
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int n;
FILE * inFile;
FILE * outFile;
inFile = fopen ("reiz.in","r");
outFile = fopen ("reiz.out","r+");
fscanf (inFile, "%s", n);
int m = n * 2;
fprintf (outFile, "%n", n);
fclose (inFile);
fclose (outFile);
return 0;
}
But something is wrong. in reiz.in file there is number 2, after running program it should output 4 in reiz.out, but it just shows don't send error. What exactly is wrong with my script? Best regards, Y2oK
EDIT 1: Ok now it looks like this -
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int n;
FILE * inFile;
FILE * outFile;
inFile = fopen ("reiz.in","r");
outFile = fopen ("reiz.out","r+");
fscanf (inFile, "%d", &n);
int m = n * 2;
fprintf (outFile, "%d", m);
fclose (inFile);
fclose (outFile);
return 0;
}
but still it gives same don't send error when running reiz.exe file, and it doesn't write anything on output file I'm now a little bit confused, and don't know who to chose as best answer, so I will chose the one who got most "+1". But thanks to all!