hello
i am new to C++ and need your help in this code.
i am trying to copy a text file in an array of string a[100] with the getline function but same is not working. below is my code.
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
//template<class T>
//struct b {
//char a[255];
//};
void main()
{
string a[100];
//struct b lines[100];
ifstream input;
input.open("c:\file2.txt");
int i=0;
if(!input)
cout<<"file not opened";
else
cout<<"file opened successfully"<<endl;
while(input)
{
input.getline(a[i],255,"\n");
i++;
}
cout<<lines[i];
thanjs and regards