so I know what my problem is I just don't know how to fix it
I want to avoid using std::string although I know that would fix my problem easily.
Note that this isn't the full code, I just included what's necessary to know (tell me if you need more)
so the problem is that >> doesn't extract whitespace. As a result, lets say you have this in lol.txt:
I want to avoid using std::string although I know that would fix my problem easily.
Code:
protected:
//Checks if string is dynamically allocated
bool isDynamic{};
//Size of the string
int bufferSize{};
//Pointer to the string
char* Buffer;
//Extract a line from an ifstream
void getline(ifstream& input)
{
char oneBuffer;
bufferSize=0;
for (int i{}; oneBuffer!='\n' && input; ++i, ++bufferSize)
input >> oneBuffer;
Buffer=new char[bufferSize];
input.close();
input.open("lol.txt");
for (int i{}; i<=bufferSize; ++i)
{
input >> oneBuffer;
Buffer[i]=oneBuffer;
}
}
so the problem is that >> doesn't extract whitespace. As a result, lets say you have this in lol.txt:
it would print thisHello World
how do I fix this?HelloWorldd
Last edited by Nyap,