#include <string>
#include <iostream>
int main() {
std::string str;
char magic[9];
std::cin.read((char *)magic, sizeof(magic));
std::cin.seekg(0, std::ios::beg);
while (std::cin >> str) {
std::cout << str << std::endl;
}
}
my code contains implementation of seekg(0) fucntion on std::cin
it is not behaving as expected on some of the files
when run as
./a.out < filename
those files that it is not behaving as expected have property that they have number of characters(including endline characters and other white spaces) less than 9(9 is the number of characters we read from cin before seekg)
if the file contains more than 9 characters it is behaving as expected for example:
123456789
will give output as
123456789
while file containing less than 9 characters will not give output
for example:
1234
will give no output