sorry im real new to c++ and can’t seem to understand the basic concept of reading a txt file and writing one. i have a program that currently just prompts the users and then delivers the output on the command line after reading the data. but i want to have it read a file, and the create a file with its output
heres it so far
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Enter number of names \n";
int a;
cin >> a;
string * namesArray = new string[a];
for( int i=0; i<a; i++) {
string temp;
cin >> temp;
namesArray[i] = temp;
}
for( int j=0; j<a; j++) {
cout << "hello " << namesArray[j] << "\n";
}
return 0;
}
Thanks to all..
1 Answer