If that makes sense, I'm attempting to convert my basic C code to C++ using C++ syntax rather than C syntax.
But I have an issue.
In C++, I'm not sure how to use strlen().
I have #include iostream> #include string> and namespace std; in preprocessing.
When I attempted to compile, I received the following error messages:
error: use of undeclared identifier 'strlen'
int n = strlen(MessagetEnc);
and
error: use of undeclared identifier 'strlen'
for (int i = 0; i < strlen(MessagetEnc); i++)
Also, #include <cstring> does not appear to solve the problem.
The code is as follows:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int EncCode;
std::cout << "Encryption code: " << std::endl;
std::cin >> EncCode;
string MessagetEnc;
std::cout << "Message to Encrypt:";
std::cin >> MessagetEnc;
std::cout << "Output: " << endl;
int n = strlen(MessagetEnc);
for (int i = 0; i < strlen(MessagetEnc); i++)
{
std::cout <<"Encrypted message" << MessagetEnc[i];
}
}
I know C++ isn't for beginners, but I wanted to give it a shot after reading a few articles, as I intend to study it thoroughly after I'm out of the "beginning stage."
Edit: std:: is there because I attempted to avoid using namespace std; as a debugging tool.