I wrote the following code in codeblocks and since I am new to programming I would like to know the problem in simple words. Does the open() constructor create a new file if it does not exists?
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
int main()
{
char str[80];
cout<<"Enter a string : ";cin>>str;
int len=strlen(str);
fstream file;
file.open("TEXT",ios::in|ios::out);
for(int i=0;i<len;i++)
file.put(str[i]);
file.seekg(0);
char ch;
cout<<"\nPrintitng Contents....\n";
int k=0;
while(file)
{
file.seekg(k);
file.get(ch);
cout<<ch;
k++;
}
return 0;
}