copying a file to an array and sorting

#include <iostream>
#include <fstream>
#include <algorithm>

int main() {
    // Step 1: Open the file for reading
    std::ifstream inputFile("input.txt");

    // Step 2: Check if the file is successfully opened
    if (!inputFile.is_open()) {
        std::cerr << "Error opening the file.\n";
        return 1;
    }

    // Step 3: Read data from the file into an array
    const int arraySize = 100; // Choose an appropriate size
    int dataArray[arraySize];
    int currentIndex = 0;
    int currentValue;

    while (inputFile >> currentValue && currentIndex < arraySize) {
        dataArray[currentIndex++] = currentValue;
    }

    // Step 4: Close the file
    inputFile.close();

    // Step 5: Sort the array
    std::sort(dataArray, dataArray + currentIndex);

    // Step 6: Display the sorted array
    std::cout << "Sorted Array:\n";
    for (int i = 0; i < currentIndex; ++i) {
        std::cout << dataArray[i] << " ";
    }

    return 0;
}