How would I write a program which, every time space was pressed, it would convert the string into a char array? This is my code so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;
int main()
{
string first;
char myword[1000];
cout << "Hello there! What would you like?" << endl;
getline (cin, first);
strcpy(myword, first.c_str());
return 0;
}
|
Also, if possible, is there a way to assign a letter to a number? For example 1 == a, 2 == b etc, just so that listing words would be easier? Or, if you guys could come up with a better solution, thank you! I did a lot of programming over the summer, stopped for a while and am only just getting back into the swing of things, so I should understand most of what your code will do.
If possible, could you explain what your code does, so that I learn what it does!
Thanks in advance, I know I'm asking a lot!