source: src/examples/ato.c @ 848fb00

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 848fb00 was 90c3b1c, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

compile CFA with C++11, further update refrat with lstlisting macros, support varags, enumeration initialization, add implicit separators to output streams, update example programs that print

  • Property mode set to 100644
File size: 1.8 KB
Line 
1//                               -*- Mode: C -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// ato.c --
9//
10// Author           : Peter A. Buhr
11// Created On       : Thu Feb  4 08:10:57 2016
12// Last Modified By : Peter A. Buhr
13// Last Modified On : Mon Feb 29 17:57:35 2016
14// Update Count     : 44
15//
16
17#include <fstream>
18#include <stdlib>                                                                               // ato, strto
19extern "C" {
20#include <stdio.h>
21#include <float.h>
22}
23
24int main( void ) {
25        int i = ato( "-123" );
26        sout | i | "-123" | endl;
27        unsigned int ui = ato( "123" );
28        sout | ui | "123" | endl;
29        long int li = ato( "-123" );
30        sout | li | "-123" | endl;
31        unsigned long int uli = ato( "123" );
32        sout | uli | "123" | endl;
33        long long int lli = ato( "-123" );
34        sout | lli | "-123" | endl;
35        unsigned long long int ulli = ato( "123" );
36        sout | ulli | "123" | endl;
37        float f = ato( "-123.456" );
38        sout | f | "-123.456" | endl;
39        double d = ato( "-123.4567890123456" );
40        sout | d | "-123.4567890123456" | endl;
41        long double ld = ato( "-123.45678901234567890123456789" );
42        sout | ld | "-123.45678901234567890123456789" | endl;
43        float _Complex fc = ato( "-123.456-123.456i" );
44        sout | fc | "-123.456-123.456i" | endl;
45        double _Complex dc = ato( "-123.4567890123456+123.4567890123456i" );
46        sout | dc | "-123.4567890123456+123.4567890123456i" | endl;
47        long double _Complex ldc = ato( "123.45678901234567890123456789-123.45678901234567890123456789i" );
48        sout | ldc | "123.45678901234567890123456789-123.45678901234567890123456789i" | endl;
49        long double _Complex ldc2 = ato( "123.45678901234-123.4567890i" );
50        sout | ldc2 | "123.45678901234-123.4567890i" | endl;
51} // main
52
53// Local Variables: //
54// tab-width: 4 //
55// compile-command: "cfa ato.c" //
56// End: //
Note: See TracBrowser for help on using the repository browser.