// // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // ato.cfa -- // // Author : Peter A. Buhr // Created On : Thu Feb 4 08:10:57 2016 // Last Modified By : Peter A. Buhr // Last Modified On : Tue Dec 4 21:33:53 2018 // Update Count : 92 // #include #include // ato, strto int main( void ) { const char * sptr = "-123"; int i = ato( sptr ); sout | i | sptr; sptr = "123"; unsigned int ui = ato( sptr ); sout | ui | sptr; sptr = "-123"; long int li = ato( sptr ); sout | li | sptr; sptr = "123"; unsigned long int uli = ato( sptr ); sout | uli | sptr; sptr = "-123"; long long int lli = ato( sptr ); sout | lli | sptr; sptr = "123"; unsigned long long int ulli = ato( sptr ); sout | ulli | sptr; sptr = "-123.456"; float f = ato( sptr ); sout | f | sptr; sptr = "-123.4567890123456"; double d = ato( sptr ); sout | d | sptr; sptr = "-123.45678901234567890123456789"; long double ld = ato( sptr ); sout | ld | sptr; sptr = "-123.456-123.456i"; float _Complex fc = ato( sptr ); sout | fc | sptr; sptr = "-123.4567890123456+123.4567890123456i"; double _Complex dc = ato( sptr ); sout | dc | sptr; sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; long double _Complex ldc = ato( sptr ); sout | ldc | sptr; sptr = "123.45678901234-123.4567890i"; long double _Complex ldc2 = ato( sptr ); sout | ldc2 | sptr; sptr = "-123"; i = strto( sptr, 0, 10 ); sout | i | sptr; sptr = "123"; ui = strto( sptr, 0, 10 ); sout | ui | sptr; sptr = "-123"; li = strto( sptr, 0, 10 ); sout | li | sptr; sptr = "123"; uli = strto( sptr, 0, 10 ); sout | uli | sptr; sptr = "-123"; lli = strto( sptr, 0, 10 ); sout | lli | sptr; sptr = "123"; ulli = strto( sptr, 0, 10 ); sout | ulli | sptr; sptr = "-123.456"; f = strto( sptr, 0 ); sout | f | sptr; sptr = "-123.4567890123456"; d = strto( sptr, 0 ); sout | d | sptr; sptr = "-123.45678901234567890123456789"; ld = strto( sptr, 0 ); sout | ld | sptr; sptr = "-123.456-123.456i"; fc = strto( sptr, 0 ); sout | fc | sptr; char * eptr = 0; // sptr = "2fred"; // fc = strto( sptr, &eptr ); // sout | fc | sptr | eptr; sptr = "2 3"; fc = strto( sptr, &eptr ); sout | fc | sptr | eptr; sptr = "-123.4567890123456+123.4567890123456i"; dc = strto( sptr, 0 ); sout | dc | sptr; sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; ldc = strto( sptr, 0 ); sout | ldc | sptr; sptr = "123.45678901234-123.4567890i"; ldc2 = strto( sptr, 0 ); sout | ldc2 | sptr; } // main // Local Variables: // // tab-width: 4 // // compile-command: "cfa ato.cfa" // // End: //