fixing warning C4244: ‘argument’ : conversion from ‘time_t’ to ‘unsigned int’, possible loss of data
I had the code bellow returing this error
warning C4244: ‘argument’ : conversion from ‘time_t’ to ‘unsigned int’, possible loss of data
class quiz {
public:
int a,b;
public:
int Crandom(){
srand(time(0));
return rand() % 6 + 1;
}
};
int main(){
cout<<&quiz::Crandom;
getch();
return 0;
}
Resolution
The resolution is just to replace This code
srand(time(0));
with
srand((unsigned int)time(0));
Related posts:
- debugging this issue with php Fatal error: Allowed memory size of 553648128 bytes exhausted (tried to allocate 261900 bytes) in
- fixing Starting httpd: Syntax error on line 35 of /usr/local/directadmin/data/users/mainr/httpd.conf: Invalid command ‘php_admin_flag’, perhaps misspelled or defined by a module not included in the server configuration
Posted by voshka @ 22 June 2011