I am having difficulty using the strcat_s() function. Concatinating char strings works find, but trying with char* string will have runtime errors. As shown here
Here is the code:
#include "Mystring.h"
#include <iostream>
#include <cstring>
#include <cctype>
int main() {
char* str1 = new char[100];
char* str2 = new char[10];
strcpy_s(str1, strlen("Hello") + 1, "Hello");
std::cout << str1;
strcpy_s(str2, strlen(" World") + 1, " World");
std::cout << str2;
strcat_s(str1, sizeof(str1), str2);
std::cout << str1;
char str3[100] = "Hello";
char str4[10] = " World";
strcat_s(str3, sizeof(str3), str4);
}
I search everywhere for the implementation of strcat_s(), and did everything as instructed but there must be some underline principles that I do not understand.