online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
// Online C compiler to run C program online #include <stdio.h> #include <math.h> #define bool int #define true 1 #define false 0 void skip_ws(const char** s) { while (**s > 0 && **s <= ' ') (*s)++; } double get_sign(const char** s) { return **s == '-' ? (*s)++, -1 : **s == '+' ? (*s)++, 1 : 1; } double parse_int(const char** s) { double r = 0; for (; **s >= '0' && **s <= '9'; (*s)++) r = r * 10 + **s - '0'; return r; } bool try_str2real(const char* text, double* const r) { skip_ws(&text); double m_sign = get_sign(&text); const char* s = text; *r = parse_int(&s); if (*s == '.') { s++; for (double p = 0.1; *s >= '0' && *s <= '9'; s++, p *= 0.1) *r += p * (*s - '0'); } *r *= m_sign; if (text == s || (text == s - 1 && *text == '.')) return false; if (*s == 'e' || *s == 'E') { s++; double p_sign = get_sign(&s); const char* sp = s; *r *= pow(10, p_sign * parse_int(&s)); if (sp == s) return false; } skip_ws(&s); return !*s; } int main() { double d; if (try_str2real("+3.14e0", &d)) printf("%lf", d); else printf("NAN"); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue