Regarding the fact tha my previous posts weren't so successful, I'd like to ask a question and I hope that I won't be banned permanently. In C++ for my semester I'll be examined in files along with many other chapters. My question is that supposing I want to handle a text document
Is :
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream thanosFile; //ofstream allows me to create and WRITE a file
thanosFile.open("thanos.txt");
thanosFile << "Hello how are you I'm fine!\n";
thanosFile.close();
}
same as:
#include "stdafx.h"
#include <stdio.h>
main(){
FILE f;
printf("Give name of file");
scanf(%s,thanosFile);
f=fopen(thanosFile, "w"); // "w" defines that I want to write the file
scanf("Hello how are you I'm fine!\n");
fclose(f);
}
?? And furthermore could someone explain me how to handle binary files? Is the approach the same? Can I do it the first way because I find it much easier because I'm getting confused with the formats of the second approach!