O
O
OCCASS OCCASSOVICH2020-06-25 17:13:24
C++ / C#
OCCASS OCCASSOVICH, 2020-06-25 17:13:24

How to print array elements from x to y?

Hello! Started learning C++, started after Python. And I have a question whether it is possible to print a certain segment of an array in C ++. Here's what it looks like in Python.

arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(arr[2:4])
#Output:
#[3, 4]

How to do the same in C++. This is what my array looks like: Thanks for the help!
char message[] = {"Hello!"};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pavlov, 2020-06-25
@OCCASS

int min;//это x
int max;//это y
for(int i=min;i<max;i++){
std::cout<<message[i];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question