Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <conio.h>
- #include <stdio.h>
- using namespace std;
- void genCharArr(char* arr) {
- //cout << sizeof(arr) / sizeof(arr[0]) << endl;
- int sz = _msize(arr) / sizeof(arr[0]);
- for (int k = 0; k < sz; ++k) {
- arr[k] = rand() % 256;
- }
- }
- void showCharArr(char* arr) {
- int sz = _msize(arr) / sizeof(arr[0]);
- for (int k = 0; k < sz; ++k) {
- cout << arr[k];
- }
- cout << endl;
- }
- void task1() {
- int sz = 10;
- char *pArr = new char[sz];
- //char Arr[13]{};
- genCharArr(pArr);
- showCharArr(pArr);
- //cout << sizeof(Arr) / sizeof(Arr[0]) << endl;
- delete[] pArr;
- }
- void test_str() {
- char str1[100]{ "Hello" };
- char str2[]{ " world" };
- strcat_s(str1, str2);
- strcat_s(str1, str2);
- cout << str1 << endl;
- strncat_s(str1, str2, 20);
- cout << str1 << endl;
- char* str3 = new char[]{ "hffhwadswsda" };
- cout << strchr(str3, 'w') << endl;
- cout << "Compare: " << _stricmp("ABC", "aBC") << endl;
- cout << "Compare: " << strcmp("DFG", "ABC") << endl;
- cout << "Compare: " << strcmp("ABC", "ABC") << endl;
- cout << "Length: " << strlen("ABCDE fg") << endl;
- char strBig[]{ "ABCdefg" };
- _strlwr_s(strBig);
- cout << "small: " << strBig << endl;
- _strupr_s(strBig);
- cout << "big: " << strBig << endl;
- _strrev(strBig);
- cout << "reverce: " << strBig << endl;
- _strnset_s(strBig, '$', 12);
- cout << strBig << endl;
- cout << strspn("ABCDEF", "EF") << endl; // ?????
- char strBig2[]{"Let me speak about the bus." };
- char* first = strstr(strBig2, "buss");
- if (first)
- cout << "It find" << endl;
- else
- cout << "Dose not find." << endl;
- //strtok_s(strBig2, " ", ppStr); // не знаем
- double x = atof("12.5");
- cout << x * 1.1 << endl;
- int k = atoi("163");
- cout << k + 23 << endl;
- long long big = atoll("12345678998545");
- cout << big << endl;
- cout << "long long: " << sizeof(long long) << endl;
- cout << "long: " << sizeof(long) << endl;
- cout << "int: " << sizeof(int) << endl;
- if (!_itoa_s(1457.6565, strBig2, 10)) {
- cout << strBig2 << endl;
- }
- }
- void task3() {
- /*
- putchar('R');
- char ch = getchar();
- cout << "You enter char: " << ch << endl;
- ch = _getch(); // #include <conio.h>
- cout << "You enter char: " << ch << endl;
- */
- char str[1024];
- gets_s(str); //#include <stdio.h>
- //cout << str;
- puts("Hello world");
- }
- void task2() {
- auto name = "Hello world";
- cout << name << endl;
- const char starr[] = "Hello world";
- cout << starr << endl;
- const char* starr2 = new char[] {"Hello world"};
- cout << starr2 << endl;
- char starr4[]{ "Hel\0 \t \n lo" };
- char starr5[]{ 'H', 'e', 'l', 'l', 'o' };
- cout << sizeof(starr4) / sizeof(starr4[0]) << endl;
- cout << sizeof(starr5) / sizeof(starr5[0]) << endl;
- cout << starr5 << endl;
- cout << '\0' << endl;
- char ch1[]{ "a" };
- char ch2[]{ 'a' };
- }
- void main() {
- //task1();
- //task2();
- //test_str();
- task3();
- }
Advertisement
Add Comment
Please, Sign In to add comment