C++ Pobieranie danych blokami z pliku txt

0

Witam otóż mam taki kod:

 #include <iostream>
#include <fstream>
using namespace std;

int main()
{
	char buffor[1024];
	fstream plik;
	plik.open("C:\\Users\\Ja\\Desktop\\cos.txt",ios::in | ios::out);
	plik.read(buffor,1024);
	plik.close();
	cout << buffor << endl;
	system("pause");
}

Wszystko działa dobrze... Wczytuje zawartosc pliku czyli 3 wiersze po 3 wyrazy wyświetla je też dobrze tylko po nich dopisuje sobie kilka lin |||||||||||||||||||||||||
Czemu?

0
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;

int main(){
    
    ifstream plik("plik.txt");
    vector<string> wszystko;
    string tmp;
    
    while(plik >> tmp)
          wszystko.push_back(tmp);
          
    for(int i=0; i<wszystko.size(); i++)
        cout << wszystko[i] << endl;
        
    cin.get();
    return 0;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1