Hi guys! I wrote a Guessing Game program for a class project and what I intend to do is as follows:
This Program is a Guessing Game! There is a number that you must guess between 1-100 and you have an infinite number of guesses. You can play as long as you want. Any number below 0 or above 100 will not be in range,
therefore you will have to try another number but it will count as a try.
If you guess the correct number, you will be notified as to how many
attempts you had. Select -1 to exit at any time. Have fun!
Unfortunately I keep getting these errors:
warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
fatal error C1075: end of file found before the left brace '{'
Can you guys help me get rid of the errors? Thanks a million in advance!
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(void) {
srand(time(NULL));
while(true) {
int number = rand() % 100 + 1;
int guess;
int tries = 0;
char answer;
while(true) {
cout << "Enter a number between 1 and 100 (" << 1000000 - tries << " tries left): ";
cin >> guess;
Thanks I appreciate it! Sorry I'm not as smooth as you would like with the code! I'm not that good at it yet.
Thanks to your help, I was able to debug it but now every value I input is basically causing the same output regardless:
"Enter a number between 1 and 100 (1000000 tries left):
And google guessing game c++ for other codes. Try and fix your code here and there. Once you think you've done your best, post your code here again with code tags, and I'll help you out.