diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0cba2e6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "iostream": "cpp" + } +} \ No newline at end of file diff --git a/Projects/C++ Projects/Basic/CPP Magic Text/text.cpp b/Projects/C++ Projects/Basic/CPP Magic Text/text.cpp index 15e4a4b..077af52 100644 --- a/Projects/C++ Projects/Basic/CPP Magic Text/text.cpp +++ b/Projects/C++ Projects/Basic/CPP Magic Text/text.cpp @@ -5,10 +5,9 @@ int main() char str[100]; - cout<<"Enter some text or numbers and see magic:-"< +#include using namespace std; int main() { int i, x; - char str[100]; + string str; - cout << "Please enter a string:\t"; + cout << "Please enter a string to convert to a secret code: "; cin >> str; cout << "\nPlease choose following options:\n"; cout << "1 = Encrypt the string.\n"; cout << "2 = Decrypt the string.\n"; + cout<<"Enter option 1 or 2: "; cin >> x; //using switch case statements @@ -24,22 +26,22 @@ int main() { //first case for encrypting a string case 1: - for(i = 0; (i < 100 && str[i] != '\0'); i++) + for(i = 0; i +#include +using namespace std; + +int main() +{ + int i, x; + string str; + + cout << "Please enter a string to convert to a secret code: "; + cin >> str; + + cout << "\nPlease choose following options:\n"; + cout << "1 = Encrypt the string.\n"; + cout << "2 = Decrypt the string.\n"; + cout<<"Enter option 1 or 2: "; + cin >> x; + + //using switch case statements + switch(x) + { + //first case for encrypting a string + case 1: + for(i = 0; i