home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March / PCWK3A99.iso / Linux / DDD331 / DDD-3_1_.000 / DDD-3_1_ / ddd-3.1.1 / ddd / stringify.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-31  |  1.7 KB  |  65 lines

  1. // $Id: stringify.C,v 1.5 1998/07/31 18:13:18 zeller Exp $ -*- C++ -*-
  2. // C-encode standard input
  3.  
  4. // Copyright (C) 1997 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller <zeller@ips.cs.tu-bs.de>.
  6. // 
  7. // This file is part of DDD.
  8. // 
  9. // DDD is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // DDD is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU General Public
  20. // License along with DDD -- see the file COPYING.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. // 
  24. // DDD is the data display debugger.
  25. // For details, see the DDD World-Wide-Web page, 
  26. // `http://www.cs.tu-bs.de/softech/ddd/',
  27. // or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.
  28.  
  29. char stringify_rcsid[] = 
  30.     "$Id: stringify.C,v 1.5 1998/07/31 18:13:18 zeller Exp $";
  31.  
  32. #include <iostream.h>
  33. #include <iomanip.h>
  34. #include <stdlib.h>
  35.  
  36. #ifndef EXIT_SUCCESS
  37. #define EXIT_SUCCESS 0
  38. #endif
  39.  
  40. #ifndef EXIT_FAILURE
  41. #define EXIT_FAILURE 1
  42. #endif
  43.  
  44. int main()
  45. {
  46.     cout << "\"";
  47.  
  48.     int p = 0;
  49.  
  50.     int c;
  51.     while ((c = cin.get()) != EOF)
  52.     {
  53.     if (p > 0 && p % 16 == 0)
  54.         cout << "\"\n\"";
  55.  
  56.     cout << "\\" << oct << setw(3) << setfill('0') << c;
  57.  
  58.     p++;
  59.     }
  60.  
  61.     cout << "\"\n";
  62.  
  63.     return EXIT_SUCCESS;
  64. }
  65.