Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions