So what's the problem? Well the output "error!" means the file could not be opened. Usually that is because it is in the wrong folder or directory. Try placing "math.txt" either in the same location as the executable (.exe on windows) or as the source code .cpp (depending on which IDE is used and how the program is run).