Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ifstream.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int counter(char* FileName);
- vector<string> ReadIn(char * FileName, int length);
- int main(int argc,const char* argv[])
- {
- char fille[256];
- cin.getline(fille,256);
- int lines = counter(fille);
- vector<string> vectors = ReadIn(fille,lines);
- cout << lines;
- for (int i = 0 ; i < lines ; i++)
- {
- cout << vectors.at(i) << " \n";
- }
- system("PAUSE");
- return 0;
- }
- int counter(char* FileName)
- {
- ifstream inFile;
- int counter = 0;
- char fileLine[256];
- inFile.open(FileName);
- while(!inFile.eof())
- {
- counter++;
- inFile.getline(fileLine,256);
- }
- counter+1;
- return counter;
- }
- vector<string> ReadIn(char * FileName, int length)
- {
- vector <string> vector1(length);
- ifstream inFile;
- char fileLine[256];
- inFile.open(FileName);
- while(!inFile.eof())
- {
- int i = 0;
- inFile.getline(fileLine,256);
- vector1.at(i)=fileLine;
- cout << vector1.at(i);
- i++;
- }
- return vector1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement