#Weird C / C# / Python / Perl / JavaScript adding strings / numbers
1 messages · Page 1 of 1 (latest)
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf( ( ("a" + 1) == "") ? "YES" : "NO");
return 0;
}
Program Output
NO
fd26 | 53ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf( ( "a" + 1 == "") ? "YES" : "NO");
return 0;
}
Program Output
NO
fd26 | 64ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf("%s", ( "a" + 1 == "") );
return 0;
}
Program Output
(null)
fd26 | 42ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf("%s", ( "a" + 1 ) );
return 0;
}
Compilation successful
fd26 | 111ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf("%c", ( "a" + 1 )[0] );
return 0;
}
Program Output
fd26 | 53ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf("%x", ( "a" + 1 )[0] );
return 0;
}
Program Output
0
fd26 | 74ms | c | x86-64 gcc 15.1 | godbolt.org
;compile C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
printf("[%s]\n", ( (("a" + 1)[0]) == (""[0]) ) ? "YES" : "NO");
return 0;
}