Function to return string of items pulled from other string | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Function to return string of items pulled from other string

I want to create an array of the characters that represent operations in the below code but can’t seem to get it to work. Anyone tell me what I’m missing? https://code.sololearn.com/c6uUfZM6asYO/?ref=app

30th Jan 2020, 5:34 AM
Shay Christensen
Shay Christensen - avatar
3 ответов
+ 3
Need a second variable <j>, for indexing in <symbolsArray>, use of <i> in your code makes the characters from <input> be copied into undesired position. for (int i = 0, j = 0; i < strlen(input); i++) { if (input[i] == '+' || input[i] == '-' || input[i] == '*' || input[i] == '/') { symbolsArray[j++] = input[i]; } else { continue; } }
30th Jan 2020, 6:20 AM
Ipang
+ 3
You're welcome, don't we all make mistakes? yes, it's fine 👌
30th Jan 2020, 3:37 PM
Ipang
+ 1
djuh on my part. simple mistake. tjanks for catching!
30th Jan 2020, 3:29 PM
Shay Christensen
Shay Christensen - avatar