Results 1 to 12 of 12

Thread: ++.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Big boObS fan sony_87's Avatar
    Join Date: Jul:2003
    Location:
    Posts: 1,254

    ++.

    ,

    , 1 . . ++:

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    
    int main(void)
    {
      char text[100];
      char substring[40];
    
      printf("\nEnter the first string :\n");
      fgets(text, sizeof(text), stdin);
    
      printf("\nEnter the second string :\n");
      fgets(substring, sizeof(substring), stdin);
    
      /* overwrite the newline character in each string */
      text[strlen(text)-1] = '\0';
      substring[strlen(substring)-1] = '\0';
    
      int i;
      for(i = 0 ; (text[i] = toupper(text[i])) ; i++);
      for(i = 0 ; (substring[i] = toupper(substring[i])) ; i++);
    
       printf(" %s \n",((strstr(text, substring) == NULL) ? "NO" : "YES"));
      return 0;
    }

  2. #2
    rootless wolfshark's Avatar
    Join Date: Dec:2005
    Location:
    Posts: 5,768
    - C C++ .
    Crashing is NOT normal. It is accepted as normal because of Windows.
    Ah the Geforce 440 MX...all the power of the Geforce 2MX, without nearly a damn being changed...

  3. #3
    Big boObS fan sony_87's Avatar
    Join Date: Jul:2003
    Location:
    Posts: 1,254
    Quote Originally Posted by wolfshark View Post
    - C C++ .
    , ++ .

  4. #4
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    1. .c .cpp
    2. C++ ,
    #include <stdio.h>

    #include <cstdio>

    , C++ , ANSI C .

  5. #5
    Registered User badboybadboy's Avatar
    Join Date: Mar:2008
    Location: sofia
    Posts: 10,496

  6. #6
    pvn's Avatar
    Join Date: Jan:2006
    Location:
    Posts: 329
    . . ++ . .

    #include <stdio.h> C++ #include <iostream>

    P.S. .

    Code:
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    using namespace std;
    
    int main(int argc, char** argv) {
    
        char *text,*substring;
        int i;
        text = new char[100];
        substring = new char[40];
    
        cout << "Enter the first string" << endl;
        cin >> text;
    
        cout << "Enter the second string" << endl;
        cin >> substring;
    
        for(i = 0 ; (text[i] = toupper(text[i])) ; i++);
        for(i = 0 ; (substring[i] = toupper(substring[i])) ; i++);
    
        cout << ((strstr(text, substring) == NULL) ? "NO" : "YES") << endl;
    
        free (text);
        free (substring);
        return 0;
    }
    Last edited by pvn; 10th December 2009 at 10:25.

  7. #7
    Bombera's Avatar
    Join Date: Jul:2001
    Location: 4EVA
    Posts: 13,833
    i .
    for(int i = 0 ...
    EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
    Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|

  8. #8
    Registered User mitkohr's Avatar
    Join Date: Jul:2001
    Posts: 1,361
    C++, :
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    class CompareStr {
    private:
            string str;
            void toUpper() {
                 int size = str.size();
                 for(int i = 0; i < size; i++) {
                         str.replace(i, 1, 1, toupper(str[i]));
                 } 
            }
    public: 
            CompareStr() {}
            
            CompareStr(const char *str) {
                this->str = str;
                toUpper();
            }
            CompareStr(const string str) {
                this->str = str;
                toUpper();
            }
            
            bool operator==(CompareStr str2) {
                 return (str.compare(str2.str) == 0);
            }
            
            friend istream& operator>>(istream& in, CompareStr& cs) {
                     in >> cs.str;
                     cs.toUpper();
                     return in;
            }
            friend ostream& operator<<(ostream& out, CompareStr& cs) {
                     out << cs.str;
                     return out;
            }
            
    };
    
    int main(int argc, char *argv[]) {
        CompareStr comp1;
        CompareStr comp2;
        
        cout << "Enter string:" << endl;
        cin >> comp1;
        cout << "Enter new string:" << endl;
        cin >> comp2;
        cout << comp1 << " and " << comp2 << " are" << (comp1 == comp2?"":" NOT") << " equal!" << endl;
    
        return 0;
    }
    Last edited by mitkohr; 10th December 2009 at 16:46.
    Gigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX

  9. #9
    pvn's Avatar
    Join Date: Jan:2006
    Location:
    Posts: 329
    STL ... ,a .
    Last edited by pvn; 10th December 2009 at 18:47.

  10. #10
    Big boObS fan sony_87's Avatar
    Join Date: Jul:2003
    Location:
    Posts: 1,254
    , . !

  11. #11
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  12. #12
    Registered User
    Join Date: Aug:2006
    Location:
    Posts: 4,052

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |