pseudolosowanie
Ostatnio zmodyfikowano 2013-01-05 10:19
kubawal |
» 2013-01-04 18:24:14 Nie można, może byc tylko NULL. Wzięte z dokumentacji: time_t time ( time_t * timer );
Get current time Get the current calendar time as a time_t object.
The function returns this value, and if the argument is not a null pointer, the value is also set to the object pointed by timer.
Parameters timer Pointer to an object of type time_t, where the time value is stored. Alternativelly, this parameter can be a null pointer, in which case the parameter is not used, but a time_t object is still returned by the function.
Return Value The current calendar time as a time_t object.
If the argument is not a null pointer, the return value is the same as the one stored in the location pointed by the argument.
If the function could not retrieve the calendar time, it returns a -1 value.
|
Krótko mówiąc, funkcja time() zwraca czas i/lub umieszcza go w zmiennej o adresie podanym jako parametr. |
|
Mrovqa |
» 2013-01-04 22:34:08 "Po pierwsze to nic nie musi. Wstawienie w funkcje time jakiejś innej wartości też sprawi, że losowana będzie liczba pseudolosowa (w funkcji rand())."
w takim razie co za róznica czy jest
time ( 1 ) a np.
time ( null ) a np. time (500) ? |
Tak, kolega nie zajrzał do dokumentacji i wprowadził Cię w błąd. Innymi słowy - funkcja naruszy pamięć odwołując się do nieswojego miejsca w pamięci. Albo podaje się adres na odpowiednią strukturę albo NULLa (standardowo w C/C++ pisze się wielkimi literami - przyjęty standard wśród programistów oznaczania makrodefinicji). /edit: Nie zauważyłem drugiej strony, przepraszam za spam. |
|
unimator |
» 2013-01-05 10:19:03 @up funkcja przyjmuje wskaźnik do struktury time_t czyli de facto jakaś wartość :). A że nie jest to zwykła liczba typu np. u int to już inna bajka. |
|
1 « 2 » |