Okay yeah i see but i'm not going for like spanish. so for example i made a code e.g. A = p, b= i and so on. so if i would do your example how could i make the computer understand the difference from like a and b for example:
1 2 3 4 5 6 7 8 9
#include <iostream>
#include <string>
int main() {
int letter;
if(letter== a ){
cout << "p";
}
}
And the user were to enter "ad" how could i have the computer distinguish a from d?
Thanks! I really appreciate any help you guys give! Sorry I'm pretty new to coding, and I'm just curious about some of this stuff.
its hard to answer this without you having a goal, but your goal seems to be 'random learning' which is fine (I do the same with some new material) but hard to guide you.
let me take a little crack:
char c; //this is a one byte integer suitable for storing english letters. int will work but its not the normal way.
string s; //this is a block of characters, can be a word or a sentence or even a full book!
c = 'a'; // 'a' is a letter. "a" is a string, though. note the different quote types.
s = "blah";
s[0] = 'z'; //s now contains zlah. [0] is the first characters, [1] is the second... so on.
you can use lookup tables for single letter swapping in english (ascii, single byte letters) easily. You also have tools with strings that can replace a letter with a string or string to string or whatever you need. This is where you need a goal before we can tell you how to do something, you need a bit more detail on what you want to do. Or you can review c++ string functions to see what you CAN do built in and beyond that you can craft your own tools to do other stuff if needed.
Okay here we go. (Thank you so much btw jonnin) So I created a "language" that I switched all the letters in. Here it is:
A = I
B = L
C = S
D = W
E = O
F = V
G = Y
H = D
I = U
J = J
K = G
L = K
M = M
N = ALX
O = E
P = R
Q = Q
R = F
S = B
T = H
U = A
V = C
W = Z
X = Mo
Y = P
Z = N
And what I want is a program that would ask the user to type in a phrase or word and it would translate it. For example: The user types in "Hello" and the computer returns: "Dokke"
@OP Oh, we have an encryption program, perhaps even a dictionary!! Good way to start.
Given the strings (eg "ALX") as part of the encoding the immediate question to be asked is are you familiar with <map>'s in C++ because setting one up and using it is ideal here. <map>'s are often called dictionary-style storage.
There are plenty of other ways from C-style arrays which the array police will leap at your throat about, or <vector>'s