online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* * hat keinen Pointer, deswegen auch keine Ausgabe dazu */ void formatMoney2(int64_t cents, FILE* stream) { bool isNegative = cents < 0; cents = (isNegative ? -cents : cents); int64_t euros = cents/100; cents -= 100*euros; // cents = 0 fprintf(stream, "%s%"PRId64".%02"PRId64" euros\n", (isNegative ? "-" : ""), euros, cents); //formatMoney } char* formatMoney3(int64_t cents) { bool isNegative = cents < 0; cents = (isNegative ? -cents : cents); int64_t euros = cents/100; cents -= 100*euros; // holt sich die cents 0.x size_t characterCount; char* result; FILE* stream = open_memstream(&result, &characterCount); formatMoney2(cents, stream); fclose(stream); return result; } void printMoney(uint64_t cents, char* (*formatter)(int64_t cents)) { char* string = formatter(cents); printf("formatMoney(%"PRId64", %p) = %s\n", cents, formatter, string); free(string); } int main() { formatMoney2(-196720000000000, stdout); formatMoney2(-314, stdout); formatMoney2(-31, stdout); formatMoney2(-3, stdout); formatMoney2(0, stdout); formatMoney2(2, stdout); formatMoney2(27, stdout); formatMoney2(271, stdout); printMoney(-196720000000000, formatMoney3); printMoney(-314, formatMoney3); printMoney(-31, formatMoney3); printMoney(-3, formatMoney3); printMoney(0, formatMoney3); printMoney(2, formatMoney3); printMoney(27, formatMoney3); printMoney(271, formatMoney3); 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