|
|
1.1 ! root 1: /* Copyright Bell Telephone Laboratories Whippany, N.J. ! 2: ! 3: * ///////////////////////////////////// ! 4: * ///////////////////////////////////// ! 5: * /////////////// str.c /////////////// ! 6: * /// J. P. Hawkins WH X4610 8C-001 /// ! 7: * ///// Thu Mar 5 10:38:56 1981 ////// ! 8: * ///////////////////////////////////// ! 9: * ///////////////////////////////////// ! 10: * @(#) str.c: V1.1 3/5/81 ! 11: * BASIC str$(expr) ! 12: * returns ASCII string representing evaluated expression ! 13: */ ! 14: #include "bas.h" ! 15: ! 16: char * ! 17: str(exp) ! 18: char exp[]; ! 19: { ! 20: double evalx(),val; ! 21: char num[40]; ! 22: char s[40]; ! 23: ! 24: val = evalx(exp); /* convert to numerical value */ ! 25: sprintf(s, "%g", val); /* convert the number to ASCII */ ! 26: num[0] = '\0'; ! 27: if(val >= 0.0) /* put blank in place of - sign */ ! 28: strcat(num," "); ! 29: strcat(num,s); /* copy number to result */ ! 30: return(num); ! 31: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.