URGENT!! Help with converting my string code to arrays

Hi guys, I have a project due today at midnight, and the instruction states,
Write a program using a function named swapFrontBack that takes as input an array of integers and an integer that specifies how many entries are in the array. The function should swap the first element in the array with the last element in the array. Test your program with arrays of different length and with varying front and back numbers. Populate the array from a file. Display array before and after function call. Declare your array to be size 25.

void swapFrontBack(int arr[], int); //function prototype

call to function :

swapFrontBack(array1, numberofelements);



Notes:

When an array is passed to a function, two parameters are usually used; one parameter specifies the specific array and the other specifies the number of elements used in the array. When an array is used as a parameter, the address of the first element is passed to the function. The function uses this address to reference values in the original array. Any changes made to the array in the function are made directly to the array argument.

In populating the array, values are read from a file and the number of records read is used as the size henceforth. When declaring an array, you can estimate the size. Example: int arr1y[25]; // This array has a size of 25 but after reading in data from file, the size is only 15. Henceforth, you will use 15 as the size.

And I actually completed the aim of this assignment, however I used string values for my program and it works perfectly. Would anyone please help me convert my code into the appropriate fashion for this project?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main ()
{
    ifstream in;
    in.open ("numbers.txt");
    
    if (in.fail())
    {
        cout << "No input file is found. Abort Program!"  << endl;
        exit(1);
    }
    
    string characters, newcharacters;
    in >> characters;
    cout << "The string characters before swapping is : " << characters << endl;
    std::iter_swap(characters.begin(), characters.rbegin());
    cout << "The string characters after swapping is: ";
    newcharacters = characters;
    cout << newcharacters << '\n';
    
    in.close();
    
    return 0;
}


Any help would be greatly and heavily appreciated. Thank you!
I have updated my code. Please take a look.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main ()
{
    ifstream in;
    in.open ("numbers.txt");
    
    if (in.fail())
    {
        cout << "No input file is found. Abort Program!"  << endl;
        exit(1);
    }
    
    string characters, newcharacters;
    in >> characters;
    cout << "The string characters before swapping is : " << characters << endl;
    std::iter_swap(characters.begin(), characters.rbegin());
    cout << "The string characters after swapping is: ";
    newcharacters = characters;
    cout << newcharacters << '\n';
    std::string str (characters);
    std::cout << "There are " << str.size() << " entries in the array.\n";
    
    in.close();
    
    return 0;
}
Topic archived. No new replies allowed.