source: src/tests/random.c@ d9b499c

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since d9b499c was ed0e67a, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add stdhdr directory to includes, containing extern "C" include wrappers for standard C include files

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[ed0e67a]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// random.c --
8//
9// Author : Peter A. Buhr
10// Created On : Tue Jul 5 21:29:30 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Jul 5 21:29:54 2016
13// Update Count : 1
14//
[5721a6d]15
16#include <fstream>
[bd85400]17#include <stdlib> // random
[ed0e67a]18#include <unistd.h> // getpid
[5721a6d]19
20int main() {
[0438091]21 rand48seed( getpid() ); // set random seed
[5721a6d]22
23 // test polymorphic calls to random and stream
[0438091]24 char c = rand48();
[5721a6d]25 sout | c | endl;
[0438091]26 int i = rand48();
[5721a6d]27 sout | i | endl;
[0438091]28 unsigned int ui = rand48();
[5721a6d]29 sout | ui | endl;
[0438091]30 long int li = rand48();
[5721a6d]31 sout | li | endl;
[0438091]32 unsigned long int uli = rand48();
[5721a6d]33 sout | uli | endl;
[0438091]34 float f = rand48();
[5721a6d]35 sout | f | endl;
[0438091]36 double d = rand48();
[5721a6d]37 sout | d | endl;
[0438091]38 float _Complex fc = rand48();
[5721a6d]39 sout | fc | endl;
[0438091]40 double _Complex dc = rand48();
[5721a6d]41 sout | dc | endl;
[0438091]42 long double _Complex ldc = rand48();
[5721a6d]43 sout | ldc | endl;
44} // main
45
46// Local Variables: //
47// tab-width: 4 //
48// compile-command: "cfa random.c" //
49// End: //
Note: See TracBrowser for help on using the repository browser.