Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
My C++ console keeps returning the same value as the last.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="omatamix" data-source="post: 472837" data-attributes="member: 84722"><p>For some reason the second command I send to my C++ console it keeps returning the same value as the last.</p><p></p><p>[CODE=cpp]</p><p>std::string delimiter = ";;";</p><p>std::string line = "";</p><p>while (std::getline(std::cin, line)) {</p><p> size_t pos = 0;</p><p> while ((pos = line.find(delimiter)) != std::string::npos) {</p><p> ttoken = line.substr(0, pos);</p><p> // std::cout << ttoken << std::endl;</p><p> if (count == 0) {</p><p> index = ttoken;</p><p> } else if (count == 1) {</p><p> token = ttoken;</p><p> } else if (count == 2) {</p><p> scoreDt = ttoken;</p><p> } else if (count == 3) {</p><p> dataEn1 = ttoken;</p><p> } else if (count == 4) {</p><p> dataEn2 = ttoken;</p><p> } else if (count == 5) {</p><p> dataEn3 = ttoken;</p><p> } else {</p><p> dataEn4 = ttoken;</p><p> }</p><p> line.erase(0, pos + delimiter.length());</p><p> count++;</p><p> }</p><p> if (index == "ready") {</p><p> std::cout << "ok" << std::endl;</p><p> }</p><p> if (index == "search") {</p><p> // set position var here.</p><p> bestMove = search.findBestMove(position);</p><p> lastBestScore = search.getLastBestScore();</p><p> std::cout << bestMove.from << "|" << bestMove.to << "|" << bestMove.bit << "|" << lastBestScore << std::endl;</p><p> }</p><p> if (index == "quit") {</p><p> break;</p><p> }</p><p>}[/CODE]</p><p></p><p>I think the problem lies in this part of this code. If you need need more part of the code let me know.</p></blockquote><p></p>
[QUOTE="omatamix, post: 472837, member: 84722"] For some reason the second command I send to my C++ console it keeps returning the same value as the last. [CODE=cpp] std::string delimiter = ";;"; std::string line = ""; while (std::getline(std::cin, line)) { size_t pos = 0; while ((pos = line.find(delimiter)) != std::string::npos) { ttoken = line.substr(0, pos); // std::cout << ttoken << std::endl; if (count == 0) { index = ttoken; } else if (count == 1) { token = ttoken; } else if (count == 2) { scoreDt = ttoken; } else if (count == 3) { dataEn1 = ttoken; } else if (count == 4) { dataEn2 = ttoken; } else if (count == 5) { dataEn3 = ttoken; } else { dataEn4 = ttoken; } line.erase(0, pos + delimiter.length()); count++; } if (index == "ready") { std::cout << "ok" << std::endl; } if (index == "search") { // set position var here. bestMove = search.findBestMove(position); lastBestScore = search.getLastBestScore(); std::cout << bestMove.from << "|" << bestMove.to << "|" << bestMove.bit << "|" << lastBestScore << std::endl; } if (index == "quit") { break; } }[/CODE] I think the problem lies in this part of this code. If you need need more part of the code let me know. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
My C++ console keeps returning the same value as the last.
Top