taking integer input from file in c++

#include <iostream>
#include <fstream>

int main() {
    std::ifstream inputFile("input.txt"); // Open the file named "input.txt" for reading
    if (!inputFile.is_open()) {
        std::cerr << "Error opening file." << std::endl; // Display an error message if the file cannot be opened
        return 1; // Return an error code
    }

    int inputNumber;
    inputFile >> inputNumber; // Read an integer from the file and store it in the variable inputNumber

    inputFile.close(); // Close the file

    // Further processing using the inputNumber can be done here

    return 0; // Return 0 to indicate successful execution
}