D
D
DAN_ON2020-09-28 10:31:52
C++ / C#
DAN_ON, 2020-09-28 10:31:52

Which function is used to convert a character string to numbers, and when and how are symbolic constants used?

Which function is used to convert a character string to a number, and when and how are symbolic constants used? and can you show how to convert a character string to a numeric one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2020-09-28
@res2001

1. std::stoi/std::strtoi and similar functions
Examples here: https://en.cppreference.com/w/cpp/string/basic_str...
2. What exactly do you not understand about the use of constants? Give an example of something you don't understand?

const int bad_id =  -1;
...
int new_id = bad_id;

The point is not to use the constant itself (in the example -1), but its named equivalent, the name of which should make sense to the reader of the code. At the same time, according to the code, you can have several identical constants with different meanings. For each such constant, you need to create your own symbolic constant.
https://ravesli.com/urok-37-simvolnye-konstanty-co...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question