void usertypedmessage(string & usermessage)
{
//Tell the user what type of message to type
cout<<"\n\nType in a message! Your message can consist of alphabets, numbers and the\nfollowing symbols ! & ? + - _ X . , : ";
//Prompt user to type a message
cin>>usermessage;
//Get each character from the string. the i is the index and should be less then the size of string
for (int i=0;i<usermessage.length();i++)
{
//Declare variable to store a character from string
char store_onechar_from_string;
//i will start at 0 and append a character
store_onechar_from_string=usermessage[i];
//The character will be used in a switch structer to print out a certain message
switch (store_onechar_from_string)
{
case'a':
for (int col=0;col<5;col++)
{
cout<<letters[0][col];
cout<<endl;
}
}
}
}
The way I might try to sole this one would be to create a monster big 2d array and the values of the big array would come from combining your smaller 2d arrays. Then when its time to print you don't print the smaller arrays, just the big one.
I think when I said small array, I meant the already defined array. well I just meant that when you go to print out your letters, it will print out the array and then to make the next letter not be under you would have to bring the cursor back to the top of the screen somehow. I am not sure how to do that so I would have a blank 2d vector array and it would get its values from the other array you already have. You should keep your switch statment so that the blank one would know in what order to assign its values. Then once the blank array is defined you can print it all out at once and it would look like a single word.
well then is there a way you can think of that will print out only the top portion of each letter before dropping to the next line and printing the next layer of each letter?
maybe putting then entire switch inside another 'for loop' and increasing the layer down with each loop.
To answer your original question, you seem to be writing an end-line after every single character. You need to write it only when you actually want to end the line, i.e. at the end of each row.
alright I came with this possible solution. I'm going to improve this furthermore. It does print it out horizontally, but the problem now is it prints out twice vertically.
ex:
A B
A B
I know it has something to do with the I, but not sure what exactly to do from now on...
void printout ( string &sentence)
{
cin>>sentence;
int length=sentence.length();
int row=0;
int column=0;
int i=0;
for (i=0;i<length;i++)
{
for (column=0;column<5;column++)
{
cout<<letters[0][column];
cout<<letters[1][column];
cout<<endl;
}
}
Well, now you seem to be writing the first letter of letters[0] and then the first letter of letters[1] on a row, then the second letter of each on the second row, and so on. Surely that's not what you want?
You need to think logically about what you're doing. Stop thinking about code, and first get the logic straight in your mind. Once you've figured out what it is you're actually trying to do in logical terms, then you can translate it into code.
Got you mikey. I know what i'm trying to do, but just can't think of an idea of how to do it in c++. I decided to make an enum data type of alphabets. User types in a sentence and then I use a string function to get the first letter. If the first letter is a certain alphabet I will have choice plugged into that value. Then I get the second letter. This seems to be a long process but I do seem to be getting an handle of this. I do need help in improving this or what you recommend. I'm only making this work for the first two letters, but once I have this figured out I have to do a whole list of alphabets. I am aware that my while loop has some incorrect logics in there. I know I have to fix that so it doesn't print out doubles of an alphabet.
enum alphbet {a,b};
void printout ( string &sentence)
{
//Enter in a sentence
cin>>sentence;
//Get first letter of alphabet
//Enum data type to store in a the alphabet value which will be storesw in the array
alphbet choice;
//Get first letter.
char letter=sentence[0];
if (letter=='a')
choice=a;
elseif (letter=='b')
choice=b;
//Get second letter?
//Get length of a sentence
int length=sentence.length();
//Column used to print out the columns
int column=0;
int i=0;
for (column=0;column<5;column++)
{
cout<<letters[choice][column];
cout<< " ";
cout<<letters[choice][column];
cout<<endl;
}
}
I did kind of aleonard, but where exactly re you pointing me to work towards O_o apologize for my lack of cooperating! but I'm jus totally lost on this and can't see how to start with it. If I just get an start to it, I'm sure I cN do it.
enum alphbet {a,b};
void printoutusersentence ( string &usertypes)
{
cout<<"\n\nType in a sentence: ";
cin>>usertypes;
int index=0;
//Get length of the string
int length=usertypes.length();
for (int column=0;column<5;column++)
{
//declare a variable to store in a character. Declare enum type variable to store in a value
alphbet store_letter_score;
char letterstore=usertypes[0];
switch (letterstore)
{
case'a':store_letter_score=a;
}
cout<<letters[store_letter_score][column];
cout<<endl;
}
}
I decide dto atleast put up a code here rather then gibbering :D :D So my algrotihm is that under the while loop, I get the first character of string and store in the enum data type alphabet. then I use the value of store_letter_score to print out the alphabet A. From this point onwards I want to see if there are more letters in the string. If there are then I get the next character and print the first row of that. So now may iget some help members :D