Question
Token in c++ I have a question about parsing line in c++. Let's say I have a line Danielt3049. If I want to parse this
Token in c++
I have a question about parsing line in c++.
Let's say I have a line "Daniel\t3049". If I want to parse this line using tab '\t',
char* token;
char buf[1000];
const char* const tab = "\t";
string line = "Daniel\t3049"
strcpy(buf, line.c_str());
if (buf[0] == 0) continue;
const string name(token = strtok(buf, tab)); const string ID((token = strtok(0, tab)) ? token : "");
Here, I have a question about that ? token : "" thing.
I understand that strtok must use null pointer as the second argument, but what is that ? token : "" thing for?
I looked up online that question mark is a condition operator. But why do we have to use condition operator in here? and -> "" , what is that double quote for?
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