home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / PCNVRT.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  731b  |  26 lines

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