Grab the tokens from the token vector and find single quot

Assignment Help C/C++ Programming
Reference no: EM13168456

There is segmentation fault in this code and I don't know where or how to fix it. The purpose of this code right here is to grab the tokens from the token vecctor and find single quotes. Then combine the single quote string into one token and the fix the rest of the token vector.

 

Example:

Label Code C'Program 5' test

This should be four tokens

Fix the code or give me a replacement.

void file_parser::check_quote(vector<string> tokens)

{

bool has_quote = false;

string tmpstr;

unsigned int FirstQuote = 0;

unsigned int SecondQuote;

string tmp;

string tmpstr2;

for (unsigned int i = 0; i <= tokens.size() - 1; i++) {

tmp = tokens[i].c_str();

for (unsigned int m = 0; m <= tmp.size() - 1; m++) {

if (tmp[m] == '\'') {

has_quote = true;

FirstQuote = m;

}

if (has_quote && m != FirstQuote && tmp[m] == '\'') {

SecondQuote = m;

for (unsigned int k = FirstQuote; k <= SecondQuote; k++) {

tmpstr += tokens[k];

}

tokens.insert(tokens.begin() + FirstQuote, tmpstr);

for (unsigned int j = FirstQuote + 1; j <= tokens.size() - 1; j++) {

for (unsigned int l = SecondQuote + 1; l <= tokens.size() - 1; l++) {

tmpstr2 = tokens[SecondQuote + 1];

tokens.insert(tokens.begin() + j, tmpstr2);

}

}

int test = tokens.size() - SecondQuote + 1;

while (test > 0) {

tokens.erase(tokens.end() - 1);

}

}

}

}

}

Reference no: EM13168456

Questions Cloud

How much heat is needed to melt ice at zero degrees : How much heat is needed to melt 22.4g of ice at zero degrees celcius to form liquid water at zero degress celcius?
Write a c program that copies the contents of one file : write a c program that copiest the contents of one file to a destination file. This program works by first prompting the user for the name of the source file and destination file.
What is the molecular weight of the gas : The density of an unknown gas is 4.00 grams per liter at 4.00 atmospheres pressure and 127 degrees C. What is the molecular weight of the gas?
Draw the structures for as well name and classify as primary : Draw the structures for and name and classify as primary, secondary, or tertiary all the isomeric amines
Grab the tokens from the token vector and find single quot : There is segmentation fault in this code and I don't know where or how to fix it. The purpose of this code right here is to grab the tokens from the token vecctor and find single quotes.
Explain what would the solubility of copper tartrate : What would the solubility of copper (II) tartrate be in a solution that contains 0.12 M sodium tartrate?
What is the vapor pressure of n-butanol : consider a flask at 298 K with an air pressure of 738 mmHg to which some n-butanol is added. If the measured pressure after the addition is 745 mmHg, what is the vapor pressure of n-butanol at 298 K?
Provide structures consistent with the molecular formulae : Provide structures consistent with the following molecular formulae and spectral data, and assign spectral peaks. Write your structures and tables on a sheet of paper.
Why does the tetrahedral intermediate for carbxylic acid : Why does the tetrahedral intermediate for carbxylic acid derivatives decompose into a carbonyl species

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd