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

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  Prepare a linux shell

Prepare a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as

  Write a program in which the program print out the input

use (switch statement) to write a program in which the program print out the input (single character) if the character is not '2','t', or 'w'. Use 'default' and 'break' wisely.

  Is a void function a function that does not return a value?

Is a void function a function that does not return a value?

  Change the inheritance to private inheritance

Take the following C++ code and make the following changes. Change the inheritance to private inheritance. Change the private data member balance to protected. Define get function members of IntAccount class to retrieve name and balance.

  A linked list of your song structure in cd

The CD object should have a data member that is a linked list of your song structure that you have in CD.  The CD class needs a function that allows it to add a song to the object, that function would then append the song to that instance of the link..

  Functions to make a main program

write the required functions to make a main program that is already written

  An integer on this system is 4 bytes long

Assume the following for the program below. An integer on this system is 4 bytes long. The memory address where the array "a[]" was created begins at location 8000. a. #include

  Write a program for find greatest common divisor

Write code for a recursive implementation of Euclid's algorithm

  Preparing a high level language program

Describe the purpose of each step in preparing a high level language program for execution (editing, compiling, linking, and loading).  Include in your description the types of files created with each of the first three steps.?

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  For this program reads the first 11 characters

E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. A..

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