home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / SNIP9404.ZIP / PCNVRT.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  645b  |  23 lines

  1. /*
  2. **  demo code for converting Pascal strings to/from C strings
  3. **
  4. **  public domain by Bob Stout
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. typedef unsigned char UCHAR;
  10.  
  11. #define P2Cconvert(s) {UCHAR n = *(s); memmove((s), &(s)[1], n); s[n] = '\0';}
  12. #define C2Pconvert(s) {int n = strlen(s); memmove(&(s)[1], (s), n); *(s) = n;}
  13.  
  14. #if (0)                             /* Demo code fragment follows */
  15.  
  16.       char string[81];
  17.  
  18.       fgets(string, 81, inFile);    /* get 80-char pascal string  */
  19.       P2Cconvert(string);           /* convert it in place        */
  20.       C2Pconvert(string);           /* convert back               */
  21.  
  22. #endif 
  23.