Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3. using namespace std;
  4.  
  5.  
  6. void IdenficatorsToUpper(char *str)
  7. {
  8.     if (str[0] >='a' && str[0]<='z')
  9.     {
  10.         int codeChar, codeInt;
  11.         char upper;
  12.         codeInt = static_cast<int>(str[0]);
  13.         codeChar = codeInt - 32;
  14.         upper = static_cast<char>(codeChar);
  15.         str[0] = upper;
  16.         for (int j = 0; j <= strlen(str); j++)
  17.         {
  18.             cout << str[j];
  19.         }
  20.         cout << endl;
  21.     }
  22.     else if (str[0]== '_')
  23.     {
  24.         cout << str << endl;
  25.     }
  26.     else
  27.     {
  28.         cout << str << endl;
  29.     }
  30. }
  31.  
  32. int main()
  33. {
  34.     int bufferSize = 50;
  35.     char *str = new char[bufferSize];  
  36.     cout << "Enter string: ";
  37.     cin.getline(str, bufferSize);
  38.  
  39.     char arr[] = " ";  
  40.     char* ptr=strstr(str,arr);
  41.     if (ptr==0)
  42.     {
  43.         IdenficatorsToUpper(str);
  44.     }
  45.     else
  46.     {
  47.         cout << "Wrong string\n";
  48.     }
  49.        
  50.  
  51.     delete[]str;
  52.     system("pause");
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement