ifstream file; file.open("myfile.txt", ios::binary); if(file.good()) cout<<"yay\n"; else cout<<"boo\n"; Everything works great if the file is not marked as read-only ...
Usually, there are dedicated applications to view different types of files. However, if you are looking for a viewer that lets you view files of multiple types, you have landed on the correct article.