online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <string.h> #include <stdlib.h> // Remove duplicate characters from sorted array void remove_dups(char *str) { char *cur = str; while(*str) { *str = *cur; while(*cur == *str) cur++; str++; } } int cmp(const void *a, const void *b) { return *(char*)a - *(char*)b; } int same_digit(int a, int b) { char A[22], B[22]; // Room for 64 bit. Increase if necessary. char Aun[11], Bun[11]; // 10 digits sprintf(A, "%d", a); sprintf(B, "%d", b); qsort(A, strlen(A), sizeof *A, cmp); qsort(B, strlen(B), sizeof *B, cmp); remove_dups(A); remove_dups(B); return !strcmp(A, B); } int main() { printf("%d\n", same_digit(1234, 4321)); printf("%d\n", same_digit(1234, 1111)); printf("%d\n", same_digit(1234, 1111342)); }

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