Error " invalid conversion from ‘char’ to ‘const char*’ " in C++. (SOLVED)
Hello, I have this code that gives me the error from the title: This is problem announcement: Given two strings and a number of successive characters "n" (large enough) from s2 to look for in s, to check if s2 is a plagiarism of s. The s string is: "HILAR". #include <iostream> #include <cstring> #include <string.h> using namespace std; int main() { char s[50], s2[50], s3[50]; int n, nrp, i; bool p; cin.getline(s, 50); cin.getline(s2, 50); cin >> n; p = false; nrp = 0; char *pp = strtok(s, ""); while (pp != NULL) pp = strtok(NULL, ""); nrp = nrp + 1; i = 1; while (i <= nrp && p == false){ strcpy(s3, pp[i]); if (strncmp (s, s3, n) != 0){ p = true; } i = i + 1; } cout << p; return 0; } https://code.sololearn.com/cKQ4yf8jw5H4/#cpp I have updated the version: Test cases: 1) Input: s = "hilar" s2 = "hila" n = 4 Output: p = 1 (TRUE) is plagiarsim. 2) Input: s = "hilar" s2 = "ir" n = 2 Output: p = 0 (FALSE) is not plagiarsim. PROBLEM SOLVED Someone can explain me how to solve this error. Thank you very much.