Results 1 to 12 of 12
Thread: ++.
Hybrid View
-
9th December 2009 20:44 #1
++.
,
, 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; }
-
9th December 2009 22:11 #2
- 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...
-
9th December 2009 22:13 #3
-
9th December 2009 22:28 #4Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
1. .c .cpp
2. C++ ,
#include <stdio.h>
#include <cstdio>
, C++ , ANSI C .
-
10th December 2009 00:57 #5
-
10th December 2009 09:49 #6
. . ++ . .
#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.
-
10th December 2009 12:33 #7
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|
-
10th December 2009 16:50 #8
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
-
10th December 2009 17:36 #9
STL ... ,a .
Last edited by pvn; 10th December 2009 at 18:47.
-
10th December 2009 22:09 #10
-
11th December 2009 10:03 #11
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
11th December 2009 10:20 #12Registered User
Join Date: Aug:2006
Location:
Posts: 4,052




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in