How do I get a number from a file?

I have an integer stored in a txt file. How do I retrieve it without using getline?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream inFile("filename.txt");
    
    int x;
    inFile >> x;    
    
    cout << "The integer from file is: " << x << endl;
}
Sorry I took a while to answer. It's working. Thanks for the help
Topic archived. No new replies allowed.