Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
3 deleted 445 characters in body
source | link

c99 gcc 265235

#include <stdlib.h>
#define O(x):--d;s[d]=s[d]x s[d+1];break;
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atofcase'+'O(v[i]+);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[case'-'O(-d]*=s[d+1];break;case')case'*'O(*)case'/':s[--d]'O(/=s[d+1];)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
H:\Desktop>type x.c
#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o
x.c:23:13: warning: return type defaults to 'int'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atofcase'+'O(v[i]+);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[case'-'O(-d]*=s[d+1];break;case')case'*'O(*)case'/':s[--d]'O(/=s[d+1];)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
x.c: In function 'main':
x.c:23:13: warning: type of 'c' defaults to 'int'
x.c:23:1: warning: implicit declaration of function 'printf''atof' [-Wimplicit-function-declaration]
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atofcase'+'O(v[i]+);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[case'-'O(-d]*=s[d+1];break;case')case'*'O(*)case'/':s[--d]'O(/=s[d+1];)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
x.c:23:2251: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
x.c:3:153: warning: incompatible implicit declaration of built-in function 'printf'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atofcase'+'O(v[i]+);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[case'-'O(-d]*=s[d+1];break;case')case'*'O(*)case'/':s[--d]'O(/=s[d+1];)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
H:\Desktop>a -4 5 +
1.000000
H:\Desktop>a 5 2 /
2.500000
H:\Desktop>a 5 2.5 /
2.000000
H:\Desktop>a 5 1 2 + 4 * 3 - +
14.000000
H:\Desktop>a 4 2 5 * + 1 3 2 * + /
2.000000

c99 gcc 265

#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>type x.c
#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o
x.c:2:13: warning: return type defaults to 'int'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c: In function 'main':
x.c:2:13: warning: type of 'c' defaults to 'int'
x.c:2:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c:2:225: warning: incompatible implicit declaration of built-in function 'printf'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>a -4 5 +
1.000000
H:\Desktop>a 5 2 /
2.500000
H:\Desktop>a 5 2.5 /
2.000000
H:\Desktop>a 5 1 2 + 4 * 3 - +
14.000000
H:\Desktop>a 4 2 5 * + 1 3 2 * + /
2.000000

c99 gcc 235

#include <stdlib.h>
#define O(x):--d;s[d]=s[d]x s[d+1];break;
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){case'+'O(+)case'-'O(-)case'*'O(*)case'/'O(/)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
H:\Desktop>gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o
x.c:3:13: warning: return type defaults to 'int'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){case'+'O(+)case'-'O(-)case'*'O(*)case'/'O(/)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
x.c: In function 'main':
x.c:3:13: warning: type of 'c' defaults to 'int'
x.c:3:1: warning: implicit declaration of function 'atof' [-Wimplicit-function-declaration]
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){case'+'O(+)case'-'O(-)case'*'O(*)case'/'O(/)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
x.c:3:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
x.c:3:153: warning: incompatible implicit declaration of built-in function 'printf'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){case'+'O(+)case'-'O(-)case'*'O(*)case'/'O(/)default:s[++d]=atof(v[i]);}printf("%f\n",s[1]);}
H:\Desktop>a -4 5 +
1.000000
H:\Desktop>a 5 2 /
2.500000
H:\Desktop>a 5 2.5 /
2.000000
H:\Desktop>a 5 1 2 + 4 * 3 - +
14.000000
H:\Desktop>a 4 2 5 * + 1 3 2 * + /
2.000000
2 added 1720 characters in body
source | link

This works for me (with warnings):

H:\Desktop>type x.c
#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o
x.c:2:13: warning: return type defaults to 'int'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c: In function 'main':
x.c:2:13: warning: type of 'c' defaults to 'int'
x.c:2:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c:2:225: warning: incompatible implicit declaration of built-in function 'printf'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>a -4 5 +
1.000000
H:\Desktop>a 5 2 /
2.500000
H:\Desktop>a 5 2.5 /
2.000000
H:\Desktop>a 5 1 2 + 4 * 3 - +
14.000000
H:\Desktop>a 4 2 5 * + 1 3 2 * + /
2.000000

This works for me:

This works for me (with warnings):

H:\Desktop>type x.c
#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o
x.c:2:13: warning: return type defaults to 'int'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c: In function 'main':
x.c:2:13: warning: type of 'c' defaults to 'int'
x.c:2:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
x.c:2:225: warning: incompatible implicit declaration of built-in function 'printf'
 float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}
H:\Desktop>a -4 5 +
1.000000
H:\Desktop>a 5 2 /
2.500000
H:\Desktop>a 5 2.5 /
2.000000
H:\Desktop>a 5 1 2 + 4 * 3 - +
14.000000
H:\Desktop>a 4 2 5 * + 1 3 2 * + /
2.000000
1
source | link

c99 gcc 265

This works for me:

#include <stdlib.h>
float s[99];main(c,v)char**v;{for(int i=1,d=0;i<c;i++)switch(!v[i][1]?*v[i]:' '){default:s[++d]=atof(v[i]);break;case'+':s[--d]+=s[d+1];break;case'-':s[--d]-=s[d+1];break;case'*':s[--d]*=s[d+1];break;case'/':s[--d]/=s[d+1];}printf("%f\n",s[1]);}

But if you are compiling it with mingw32 you need to turn off globbing (see https://www.cygwin.com/ml/cygwin/1999-11/msg00052.html) by compiling like this:

gcc -std=c99 x.c C:\Applications\mingw32\i686-w64-mingw32\lib\CRT_noglob.o

If you don't * is automatically expanded by the mingw32 CRT.

Does anybody know how to turn break;case'*':s[--d]*=s[d+1]; into a macro that accepts the character + as a parameter because then all four cases would just be O(+)O(-)O(*)O(/)