Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:13:45+00:00 2026-05-29T17:13:45+00:00

I made a simple program that allows the user to pick a number of

  • 0

I made a simple program that allows the user to pick a number of dice then guess the outcome… I posted this code before but with the wrong question so it was deleted… now I cannot have any errors or even warnings on this code but for some reason this warning keeps popping and I have no clue how to fix it…
“warning C4244: ‘argument’ : conversion from ‘time_t’ to ‘unsigned int’, possible loss of data”

#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>

using namespace std;

int  choice, dice, random;

int main(){
    string decision;
    srand ( time(NULL) );
    while(decision != "no" || decision != "No")
    {
        std::cout << "how many dice would you like to use? ";
        std::cin >> dice;
        std::cout << "guess what number was thrown: ";
        std::cin >> choice;
         for(int i=0; i<dice;i++){
            random = rand() % 6 + 1;
         }
        if( choice == random){
            std::cout << "Congratulations, you got it right! \n";
            std::cout << "Want to try again?(Yes/No) ";
            std::cin >> decision;
        } else{
            std::cout << "Sorry, the number was " << random << "... better luck next  time \n" ;
            std::cout << "Want to try again?(Yes/No) ";
            std::cin >> decision;
        }

    }
    std::cout << "Press ENTER to continue...";
    std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
    return 0;
}

This is what I am trying to figure out, why am I getting this warning:
warning C4244: ‘argument’ : conversion from ‘time_t’ to ‘unsigned int’, possible loss of data

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:13:46+00:00Added an answer on May 29, 2026 at 5:13 pm

    That’s because on your system, time_t is a larger integer type than unsigned int.

    • time() returns a time_t which is probably a 64-bit integer.
    • srand() wants an unsigned int which is probably a 32-bit integer.

    Hence you get the warning. You can silence it with a cast:

    srand ( (unsigned int)time(NULL) );
    

    In this case, the downcast (and potential data loss) doesn’t matter since you’re only using it to seed the RNG.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an assignment I've made a simple C++ program that uses a superclass (Student)
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we
I'm learning java and I have made simple program that simply reads value from
Hi i have made a simple program that plays a video file, i used
I have a made a simple program that reproduces the problem: #include <boost/archive/text_oarchive.hpp> #include
I made a simple java program that sends bytes to the parallel port, which
I made a program that is supposed to recognize a simple grammar. When I
I made a simple program that uses a shared object, opening it with dlopen()
i've made a simple program that change a string from lowercase to uppercase and
I have made my own file type (.ddd) and I made a simple program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.