visual studio 2010 - C++ Not displaying Random number correctly -


i want generate random number temperature. code used below:

int temp() {     // genreate random temperture      // initialize random seed:      srand ( time (null) );      // generate number between 1 , 100:     int t = rand() % 100 + 1;      std::cout << t << std::endl;     return t; } 

when program run, instead of displaying number between 1 , 100, display following:

010c1109 

could explain or why going wrong?

edit: if wondering used following:

#include <iostream> #include <string> #include <fstream> #include <istream> #include <ctime> #include <stdio.h>       #include <stdlib.h>     #include <time.h>      #include <map> #include <cstdlib> #include <cstring> #pragma once 

how choose way numbers displayed:

std::cout << std::hex << t << std::endl; //displays in hexadecimal std::cout << std::dec << t << std::endl; //displays in decimal 

in example see 58 in hexadecimal , 88 in decimal (5*16+8). here official links making post complete.

c++ forum:

http://www.cplusplus.com/forum/windows/51591/

details explained:

http://www.cplusplus.com/reference/ios/dec/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -