lundi 3 octobre 2016

I'm having trouble having my program to show an input file after I made modifications to it

Basically my code is supposed to be a text formatter where I'm given certain directions and it prints out the input file. One of the specifications is that if it sees ".ll" it will look to see if it's an integer. if it is and it's between 10 and 120 to make the paragraph that set length.

The problem is that it's only showing ".ll". Here's my code


#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <stdexcept>
using namespace std;
ifstream text("test.txt");
string line;
string word;
stringstream ss(line);
string ll=".ll";
string str1;
int f;



  int main(){
  void push_back (char c);
    if (text.is_open()){
    while(getline(boston, line) ){
    int finder = line.find(ll);
    if(finder != std::string::npos){
        str1 = line.substr(4,std::string::npos);
        try{
            f = std::stoi(str1);
            if(f>=10&&f<=120){
                try{
                    if(str1.length()<=3){
                       line.push_back();
                        cout<<line<<endl;
                    }
                }
                catch(std::out_of_range&oor){
                    cout<<std::setw(f);
                }
            }
            }
        catch(std::invalid_argument){
        }
        }
    }
//cout<setw(f)<<Line2<<endl;
    text.close();
}}

Aucun commentaire:

Enregistrer un commentaire