Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- std::vector<std::string> ReadParagraph(FILE *pFile);
- int main()
- {
- std::vector<std::string> DoanVan;
- std::string str(""), tmp, str1, str2;
- char cStr[255];
- FILE *pFile;
- pFile = fopen("In.txt", "rt");
- if ( !pFile ) std::cout << "File Error \n";
- DoanVan = ReadParagraph(pFile);
- std::cout << "\n";
- for (int i = 0; i < DoanVan.size(); ++i)
- {
- std::cout << DoanVan[i];
- system("pause >> NULL");
- }
- fclose (pFile);
- return 0;
- }
- std::vector<std::string> ReadParagraph(FILE *pFile)
- {
- char Buff[255];
- int n = 1, i = 0;
- std::vector<std::string> Para(n); // Paragraph
- while ( !feof(pFile) )
- {
- fgets(Buff, 255, pFile);
- Para[i] = Para[i] + Buff;
- if ( strchr(Buff, '\n') )
- {
- if ( Para[i] == "\n" )
- {
- Para[i] = "";
- }
- else
- {
- ++n;
- Para.resize(n);
- ++i;
- }
- }
- }
- return Para;
- }
Advertisement
Add Comment
Please, Sign In to add comment