How would you make each line a certain amount of characters?

I have to create a text formatter and the first part is that I have to make each line of each string from a text file 60 characters by default. How would I go about doing that?

Here is my code so far.

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
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>       //isspace,
#include <cstdio>       //
#include <vector>
using namespace std;

int main(int argc, char* argv[])
{
    string line;
    
    
    if(argc != 2)
    {
        cout << "There must be 2 arguments to run program correctly.\n";
        return -1;
    }
    
    ifstream infile(argv[1]);       //open file
    
    if(infile.fail())       //if file cannot be opened, end program.
    {
        cout << "Error opening file.\n";
        return -1;
    }
    else        //else, start text formatter
    {
        while(getline(infile,line))
        {
            cout << line << endl;
        }
        
    }
    
    return 0;
}
Topic archived. No new replies allowed.