#include <iostream>
#include <iomanip>
int main()
{
char file_name[128] ; // declare an array to hold the file name
std::cout << "file name: " ;
// std::setw( sizeof(file_name) ): do not accept more chars than what the array can hold
std::cin >> std::setw( sizeof(file_name) ) >> file_name ;
std::cout << file_name << "\n" ;
}
Simpler to use std::string instead of the c-style array.
Yes, using an std::string would be perfect, but it is also giving me an error if I try
to read into an uninitialized char* from a file, how can I user std::ifstream::read
to read into an std::string?
Oh, so you can't read a set amount of bytes?
Hmmm I am currently trying to develop a
binary file format that has a width and length
for a square... Hmm