Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble reading input from a file and converting it to a string. The input is supposed to be: 6 3 and I want

I'm having trouble reading input from a file and converting it to a string. The input is supposed to be:

6 3

and I want to save 6 and 3 in separate integer variables. This is the code I have.

char *com, *dummy, *valstr, *op;

while (getline(input2,hold)) {

com = strdup(hold.c_str());

op = strtok(com, " \t");

valstr = strtok(NULL, " \t");

if(valstr != NULL)

l = strtol(valstr, &dummy, 10);

l--;

cout << l << endl;

com = strdup(hold.c_str());

op = strtok(com, " \t");

valstr = strtok(NULL, " \t");

if(valstr != NULL)

f = strtol(valstr, &dummy, 10);

cout << f << endl;

if (words[l].head==NULL || l>SIZE) {

output <<"- ";

break;

}

output << words[l].search(f) << endl;

if (words[l].search(f)=="-" || words[l].head==NULL) {

output <<"- ";

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions