Im trying to copy a whole .txt file into a char array. My code works but it leaves out the white spaces. So for example if my .txt file reads \"I Like Pie\" and i copy it to
Here is the code snippet you need:
#include
#include
#include
#include
int main()
{
std::ifstream file("name.txt");
std::string str((std::istreambuf_iterator(file)),
std::istreambuf_iterator());
str.c_str();
for( unsigned int a = 0; a < sizeof(str)/sizeof(str[0]); a = a + 1 )
{
std::cout << str[a] << std::endl;
}
return 0;
}