Tic tac toe challange, my code gets stuck in while loop
Codecademy Forums » C++
by jmisheski
1M ago
My code works fine up until my while loop catches a player picking a spot already chosen. when this happens, the game gets stuck in the while loop no matter what the player chooses. the code creates a vector to store each space. when a player chooses a spot (1-9) the value of that assigned value is changed to the players mark X or O. a current game board and the instruction board, to remind players what spot is what number, is printed each turn. please help. ttt.cpp #include <iostream> #include "ttt_func.hpp" #include <vector> int main() { std::vector<char> answer ..read more
Visit website
Compile errors for no known bool conversions, though function and arguments is not a bool
Codecademy Forums » C++
by flurryi
1M ago
Hello! I’m having compile errors about a bool conversion error, though there is no bools in any of my code, and the return type of my function which the code resides in is also not a bool, either. int path(std::string input, int type) { if (type == 0 and input == "L") { return 1; //player selected left } else if (type == 0 and input = "R") { return 2; //player selected right } } I’ve tried using && and and to make this code work, but it expects a bool conversion for the std::string input variable. I don’t know what’s causing the error, and I don’t want to switch the fun ..read more
Visit website
Cannot compile optional challenges
Codecademy Forums » C++
by bit1820549950
2M ago
I’m trying to learn C++ but whenever I try to do the optional challenge at the end of a lesson and try to compile my code by writing “cpp review.cpp” I am hit with a stream of error message gibberish–even if I haven’t even written anything. Please help! (link: https://www.codecademy.com/courses/learn-c-plus-plus/lessons/cpp-conditionals-and-logic/exercises/review) 2 posts - 2 participants Read full topic ..read more
Visit website
RPS Logic?
Codecademy Forums » C++
by codebanger995
2M ago
Here’s the issue that I’m having. There’s 2 but one more important than the other. the srand doesn’t seem to be giving random items. When I’m looking at the function it seems to be correct. Here is what is happening. The computer value seems to be putting out 2 and that’s it. no matter the time. I tried moving functions around in different orders and it seems that doesnt work. The other issue that im having is that even when it adds the 1 to the non random number, it still sees it as 1. So the output is displaying 2 but the if statements see 1. So when ever i test it, it says it ties when i ..read more
Visit website
No match for ‘operator=’
Codecademy Forums » C++
by arc3340522272
2M ago
i am trying to give ch a string value from a map with the find() function but its giving me an error(no match for ‘operator=’). how can i fix that? 2 posts - 2 participants Read full topic ..read more
Visit website
If statement being ignored despite conditions being true
Codecademy Forums » C++
by ruby3856350253
2M ago
Hello all, I’ve been working on a quiz game program for my class, and it includes if statements for a menu selection screen. The program was almost complete, and I was going to finish it today, but when I opened up the project to test out the endless mode, the menu selection screen began repeating itself. I tested it JUST before I signed out of the computer yesterday, and this problem was not occuring. Nobody else signed into my computer and tampered with the code, no errors/warnings relating to the if() statements are being shown, and I am seriously confused. What the ■■■■ is up with my code ..read more
Visit website
Writing and reading 0-255 in C++
Codecademy Forums » C++
by mega7379305288
2M ago
Hi guys. What can I use to write and read, in order to deal with the full character set 0-255? I include the program that will prove that it doesn’t work. This is the best write and read I could find. I’m using Visual C++ Thank you. unsigned char Ch1; int ix, iNumOut; const string TEST_FILE = “T1.DAT”; // Write ofstream testout(TEST_FILE, ios::binary); for (ix = 0; ix <= 255; ix++) testout << char(ix); testout.close(); // Read ifstream testin(TEST_FILE, ios::binary); for (ix = 0; ix <= 255; ix++) { testin >> Ch1; iNumOut = Ch1; cout << iNumOut << ", "; } testin.cl ..read more
Visit website
Help plz
Codecademy Forums » C++
by arc3340522272
2M ago
how its possible? 1 post - 1 participant Read full topic ..read more
Visit website
C++ is seemingly doing division incorrectly
Codecademy Forums » C++
by digital3025981996
2M ago
I am trying to make a program to check if any given year is a leap year, I found the (n % 2 == 0) equation and it was great but as soon as I put it in a Boolean and then the bool in an if else statement it started giving me numbers that don’t make sense, I tried to reverse engineer the numbers but I can’t make any sense out of why it spitting those numbers out. I#include int main() { //variables int year = 2020; //check if divisible by four std::cout << "Enter year: "; std::cin >> year; //Years leap check bool divfour = (year % 4 == 0); bool divqhund; if (year % 100 == 0) { bool di ..read more
Visit website
I'm trying to make a simple code, but std::cin is being skipped
Codecademy Forums » C++
by tera6659508477
3M ago
Hello there! I’m starting to learn how to code, and based on the lesson about “vectors”, I made this simple code. The problem is that the Codecademy workspace is skipping my std::cin and is just printing everything at once. How can I fix this? I’m also accepting feedback! This is my code: #include <iostream> #include <vector> int main() { int even = 0; int odd = 1; int input; std::vector<int> numbers; for (int o = 5; o > numbers.size(); o--){ std::cout << "Please input " << o << " more numbers\n"; std::cin >> input; numbers.push_back(input ..read more
Visit website

Follow Codecademy Forums » C++ on FeedSpot

Continue with Google
Continue with Apple
OR