Category : Miscellaneous Language Source Code
Archive   : CLC501.ZIP
Filename : DESKTOP.C

 
Output of file : DESKTOP.C contained in archive : CLC501.ZIP
/*.t|Clist demonstration using K&R pages 74-79*//*.function .author Kernighan & Ritchie*/
/* A $2,000 desktop calculator that isn't even programmable! */
/* This listing produced using the following command line:
CLC -C-G-H-PBI-T-D DESKTOP > DESKTOP.LST
*/

/* Foreign characters
won't be thrashed: €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬­ */
/* Nor will literal line-drawing characters in quotes: "³´µ¶·¸¶º»¼½¾¿ÀÁÂÃ" */

/* .noin Don't include the (long) standard headers */
#include
#include
#ifdef SAMPLE
#include "sample.h"
#endif
/* .incl Include the other files */

#define MAXOP 20
#define NUMBER '0'
#define TOOBIG '9'

#include
#include
#include

main()
{
int type;
char s[MAXOP];
double op2, atof(), pop(), push();

while ((type = getop(s,maxop)) != EOF) {

switch (type) {

case NUMBER:
push(atof(s));
break;
case '+':
push(pop() + pop());
break;
case '*':
push(pop() * pop());
break;
case '-':
op2 = pop();
push(pop() - op2);
break;
case '/':
op2 = pop();
if (op2 != 0.0)
push(pop() / op2);
else
printf("Zero divisor popped\n");
break;
case '=':
printf("\t%f\n",push(pop()));
break;
case 'c':
clear();
break;
case TOOBIG:
printf("%.20s ... is too long\n");
break;
default:
printf("unknown command %c\n",type);
break;
}
}

/* end of program, desktop.c */



  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : CLC501.ZIP
Filename : DESKTOP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/