I have tried to make it using dynamic string array but when I tried to add 2 lines it only adds one I don't know why here is my code
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int x;
string name;
string* lines;
cout << "Input the file name to be opened : ";
cin >> name;
cout << endl << "Input the number of lines to be written : ";
cin >> x;
lines = new string[x];
cout << endl << "The lines are :";
for (int i = 0; i < x; i++)
{
getline(cin,lines[i]);
}
fstream File(name, ios::out | ios::app);
for (int i = 0; i < x; i++)
{
File << lines[i] << endl;
}
File.close();
}
and it gives me this warning: C6385 Reading invalid data from 'lines': the readable size is '(unsigned int)*28+4' bytes, but '56' bytes may be read