OK im ok with some baisc codeing but i cose to go a little farther and write some more in detailed stuff so i started making a few fuctions. iv done this once before, but i cant remeber what i did diffrent.
The function takes a file and reads each line untill its read X number of lines, then returns that line.
what am i doing wrong!!!
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
//
// The following function reads a line specified by the function, and outputs it.
string read_file(string file, int line)
{
string current_line;
int i;
ifstream current_file(file.c_str());
for( i = 1; i < line + 1; i++)
{
getline (current_file, current_line);
}
cout << current_line;
current_file.close();
return current_line;
}