Hey, Im new to C++ and decided to make a program that dissects user input into a 3xwhatever matrix and multiplies it by an encode matrix, thus make a coded message! However, I am having some trouble taking the user input apart, and putting it into arrays.
Anyone have any idea how to take apart different parts of the user input, or if this is way to advanced for a beginner.. thanks!
It depends on what data type you want. For ease of programming and versatility, I would suggest std::string. Its like a char array, but WAY better and much less error prone. Getting user input would be a snap, and you can access individual elements just like a normal array with the [] operator. Like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <string>
usingnamespace std;
int main(){
string input;
cout << "Enter a string: ";
getline(cin, input); //extracts chars until ENTER is pressed (in plain...ish english)
for (int c = 0; c<input.size(); c++){
encrypt(input[c]);} //just like an array here (encrypt doesn't exist, you need to replace that with your own
cout << input; //no need to loop to display, unlike raw arrays
return 0;}