How to Read a string vector character by character

I need help with my program. I need to create a file formatter where i read from a file, create a new file and format the contents from the original file to 60 characters per line. if i come across ".ll 44" in the file, i must format from to 44 characters per line. if i come across ".llN" i must create a new paragraph. The only issue im having is figuring out how to read each string element in my vecter charactor by character, and if i come across a ".ll 55", how do i cast from the 55 from string to int so i can reset the line length
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <fstream>
# include <ctime>
# include <cstring>
# include <vector>
using namespace std;


int main(int argc, const char * argv[])
{
    int count =0;
    ifstream file;
    ofstream answer;
    string paragraph = ".llN";
    
    file.open("test.txt");
    answer.open("answer.txt");
    
    vector<string> myvec;
   // string arr[100];
    int length =20;
    string temp = "";
    while(!file.eof())
    {
        file>>temp;
        myvec.push_back(temp);
        myvec.push_back(" ");
    }
    
    for(unsigned int i; i < myvec.size(); i++)
    {
        count++;
        
        if(count == length)
        {
            if(myvec[i+1] == " ")
            {
                myvec[i]= "\n";
                count = 0;
                //answer<<"\n";
            }
            else
            {
                count = 0;
                answer<<"\n";
            }
       
        }
        else if(myvec[i] == ".llN")
        {
            answer<< "\n";
            myvec[i+1] = "";
        }
        else if(myvec[i] == ".ll")
        {
            myvec[i] = "";
            //length = myvec[i+1];
            myvec.at(i);
            
        }
        else
        {
            answer<<myvec[i];
        }
    }
}


My test file: 

Now this is the story all about how My life got flipped, turned upside down And I'd like to take a minute just sit right there I'll tell you how I became the prince of a town called Bel Air In west Philadelphia born and raised On the playground where I spent most of my days Chilling .llN 65 out, maxing, relaxing all cool And all shooting some b-ball outside of the school When a couple of guys who were up to no good Started making trouble in my neighborhood I got in one little fight and my mom got scared And said you're moving with your auntie and uncle in Bel Air Read more: Will Smith - The Fresh Prince Of Bel Air Lyrics | MetroLyrics 

After my code runs:

Now this is the story all about how My life
got flipped, turned upside down And I'd like to take
a minute just sit right there I'll tell you how
I became the prince of a town called Bel Air
In west Philadelphia born and raised On the playground where
I spent most of my days Chilling 
65 out,
maxing, relaxing all cool And all shooting some b-ball outside
of the school When a couple of guys who were
up to no good Started making trouble in my neighborhood
I got in one little fight and my mom got
scared And said you're moving with your auntie and uncle
in Bel Air Read more: Will Smith - The Fresh
Prince Of Bel Air Lyrics | MetroLyrics MetroLyrics 


All Help is greatly appreciated
closed account (48T7M4Gy)
Sounds like you need to search the strings in question for sub-strings:

http://www.cplusplus.com/reference/string/basic_string/find/
Topic archived. No new replies allowed.