Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

c++ - Three Integers into 1 string with spacebars;

I have input like this:

1581 303 1127 Bravo

I want to put it into strings like this:

string a="1581 303 1127";
string b="Bravo";

How can i do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Based on the fact that you take first three as int and last as string do it like this.

int i1, i2, i3; //Take input in three integers sprintf(a, "%d %d %d", i1, i2, i3);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...