Pavel3333 Posted September 16, 2017 Share Posted September 16, 2017 (edited) int main() { char buff[4]; std::ifstream file("Hull_mask.primitives", std::ifstream::binary); std::ofstream out("Hull_mask_enc.primitives", std::ifstream::binary); while (file) { file.read((char*)&buff, sizeof buff); out.write((char*)&buff, sizeof buff); } file.close(); system("pause"); return 0; } лишний раз записывается содержимое буферной переменной. Решил так: while (file) { file.read((char*)&buff, sizeof buff); if (!file.eof()) out.write((char*)&buff, sizeof buff); Edited September 16, 2017 by Pavel3333 1 @ Quote Link to comment Short link Share on other sites More sharing options...
SkepticalFox Posted September 17, 2017 Share Posted September 17, 2017 Это не C++ way) @ Quote Link to comment Short link Share on other sites More sharing options...
Pavel3333 Posted September 17, 2017 Author Share Posted September 17, 2017 Это не C++ way)А я по-всякому пробовал. Если делать file >> buff, это работает до первого нулевого символа. То есть дальше 7 байт я не уйду.StreamReader? Не люблю CLR, только хардкор. :) @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.