Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started