Ostrzeżenie:C++ ostrzeżenie rozwiązywania istream :: tellg
warning C4244: 'initializing' : conversion from 'std::streamoff' to 'unsigned int', possible loss of data
Spowodowany przez:
unsigned int FileSize = File.tellg(); // WARNING
std::cout << "Size = " << FileSize << std::endl;
Możliwe rozwiązanie? Czy można to zrobić:
// No more warnings but, is it safe?
unsigned int FileSize = (unsigned int)File.tellg(); // OK?
std::cout << "Size = " << FileSize << std::endl;
Co z tym?
// No more warnings but, is it safe?
unsigned int FileSize = static_cast< unsigned int >(File.tellg());
Oba rozwiązania są w porządku. [Sugeruję, żebyś czytał o castach] (http://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-and-reinterpret-cast-be-used) – Cornstalks
OK, po prostu chciałem upewniać się. – user2117427
Czy istnieje powód, dla którego nie chcesz 'std :: streamoff FileSize = File.tellg();'? – nobar