M
M
Maxim Siomin2020-06-26 18:54:16
C++ / C#
Maxim Siomin, 2020-06-26 18:54:16

How to split a string in c++?

You need to split the string by sign. That is something like this:

#include <iostream>

int main()
{
    int a;
    std::cin >> a;
//пользователь ввел 23+56

Now the program must split the string by the + symbol, and understand which is the first number and which is the second.
Here is a python solution:
a = input()
a = a.split('+')
num1 = a[0]
num2 = num[1]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei Chamkin, 2020-06-26
@MaxSiominDev

https://www.fluentcpp.com/2017/04/21/how-to-split-...
https://www.cyberforum.ru/cpp-beginners/thread1623...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question