Hmm I found that the problem is diferent than what I had previously believed...I am using that char table we talked about a few days ago and it seems that when it takes in a white space it converts it to a strange character that will display in a text editor properly, but when displayed using cout it will show something like This?is?my?message.
So the problem is not in displaying it, it is at the root of the text generator..So with that being said, any suggestions on how to run the string through the char table while still holding onto the white spaces as just a blank space?
This is basically how its running now with char table algorithm changed and unnecessary text omitted:
Code:
void rep(char& c)
{
bool up_flag(c>='A'&&c<='Z');
if(up_flag)c=tolower(c);
static char table[]=
{
'a','b','c','d','e',
'f','g','h','i','j',
'k','l','m','n','o',
'p','q','r','s','t',
'u','v','w','x','y',
'z'
};
c = table[c-'a'];
if(up_flag)c=toupper(c);
}
int main()
{
string filename;
string message;
cout<<"Filename: ";
getline (cin, filename);
cout<<"*MESSAGE*\n";
getline (cin, message);
for_each(message.begin(),message.end(),rep);
ofstream a_msg(filename.c_str());
a_msg<<message;
a_msg.close();
}