Home > Back-end >  Creating serial text output with a text
Creating serial text output with a text

Time:06-30

Hello I want to know how can I make a code like i want to input a number XXX it will output

ChinaXXX BeijingXXX-CHINA-XXX 180243189(XXX)

Like this. Advance thanks Sorry for the title. I dont how can i said about on title.

CodePudding user response:

#include <iostream>
#include <string>

int
main()
{
  std::string number;
  std::cin >> number;
  std::cout << "China" << number << " Beijing" << number
        << "-CHINA-" << number << "  180243189(" << number << ")"
        << std::endl;
}

CodePudding user response:

Or if you have C 20 available, use std::format

#include <format>
#include <iostream>
#include <string>

int main()
{
    std::string number;
    std::cin >> number;
    std::cout << std::format("China{0} Beijing{0}-CHINA-{0}  180243189({0})\n", number);
    return 0;
}
  •  Tags:  
  • c
  • Related