Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- #include <string.h>
- #pragma warning(disable:4996)
- int main()
- {
- // static
- char str1[11];
- str1[10] = '\0';
- strcpy(str1, "abcdefghij");
- // dynamic
- // str2 is now considered a char*
- char* str2;
- str2 = new char[11];
- // str2 is now converted to a dynamic array of char
- // for 11 elements
- str2[10] = '\0';
- // we declare the element 10 to have a null-terminator
- strcpy(str2, str1);
- std::cout << str1 << std::endl << str2;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement