home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / brklyprl.lha / Emulator / Instructions / chcase.c next >
Encoding:
C/C++ Source or Header  |  1989-04-14  |  595 b   |  38 lines

  1.  
  2. /* Copyright (C) 1988, 1989 Herve' Touati, Aquarius Project, UC Berkeley */
  3.  
  4. #include <stream.h>
  5. #include <ctype.h>
  6.  
  7. extern int strlen(char*);
  8. main()
  9. {
  10.   char buf1[80];
  11.   char buf2[80];
  12.   char* p = buf1;
  13.   char* q = buf2;
  14.   char* p0;
  15.   int first_flag = 1;
  16.  
  17.   cin >> buf1;
  18.   if (strlen(buf1) >= 80) {
  19.     cerr << "Too long an input\n";
  20.     exit(1);
  21.   }
  22.  
  23.   p0 = p + strlen(buf1);
  24.  
  25.   for (; p < p0; p++) {
  26.     if (*p == '_') {
  27.       first_flag = 1;
  28.     } else if (first_flag) {
  29.       first_flag = 0;
  30.       *q++ = toupper(*p);
  31.     } else {
  32.       *q++ = *p;
  33.     }
  34.   }
  35.   *q = '\0';
  36.   cout << buf2;
  37. }
  38.