Hello everybody and good afternoon. So I'm still new-ish to this scene but have quite the ambition for it and I've been trying to learn as much as i can. i consider myself to be adept in c++ but I've always programming DOS programs and recently I've broadened my horizons to the Windows API.... with that being said, I've noticed that Windows API is greatly intertwined with UNI-CODE while DOS used ANSI.. so i know that ANSI uses 8-bit character codes and UNI-CODE uses 16-bit.. so my questions are:
1) why is this important.. is it more specific or able to hold more information since its 16 bits verses 8? i mean i know that there are some characters that ANSI does not support that UNI-CODE does but is that it??
2) What's the difference between TCHAR and WCHAR and is it just the 16 bit version of char? if WCHAR is wide char then whats TCHAR?
3)I understand that LPWSTR is long pointer to wide string but when would you use this and why? is it just a windows thing? and isn't a long pointer automatically 16 bits? Does that mean a regular pointer is 8 bits? if so why would you need the extra bits?
4)Next why would you need wstring and would you need to use wchar and tchar with it for certain functions? i.e.
wstring myStr;
TCHAR myChar;
if (myStr.find(myChar) != string::npos) { krmormrm }
or does it matter..
char myChar;
if (myStr.find(myChar) != string::npos) { jnrnikvnr }
5) Last but not least, i had trouble displaying WCHAR and wstring or even int without a conversion.. for instance (i figured it out sort of) i did:
WCHAR myChar = '1';
int i = 2;
wstring myString;
ofstream File1("myFile.txt");
if (File1.is_open())
{
File1 << (char)myChar; //if i didn't typecast it to char it displayed 49 instead of 1;
File1 << (WCHAR)i; //if i didn't typecast it to WCHAR(like to char instead)it displays symbols
WCHAR temp;
copy(myString.begin(), myString.end(), temp);
File1 << (char)temp;
}
ok so i had a little problem with the wstring and copy. what i did in my real program (this was just a quick rescript) was took 9 WCHAR variables... used wstringstream to load them all into its variable(wss) and then into myString(my wstring variable)... so to make sure they all loaded correctly i copied it into a WCHAR temp to send it to file1 so i could physically see what loaded into it but for some reason it loaded the variables i wanted AND extra variables i didnt want and ive gone over the code multiple times and found nothing wrong.. so i got rid of the copy function and displayed each variable individually with a for loop like:
for (int i = 0; i < 81; i++)
{
File1 << "Box " << (WCHAR)i << ": " << (char)BoxNum[i] << "\n";
}
and i concluded everything held the correct values... just fyi i was inputting the values into a text box and retrieving the text and storing it in individual variables.. the text boxes are lined up 9 by 9... so there's 9 in a row and 9 in a column... and then i used the variables from the boxes in the first row and put it in myString so i could just use the string.find() function to check for numbers in that row instead of box by box.. my problem was displaying this wstring...... ANYWAYS lol sorry just trying to provide as much info as possible, maybe someone can solve that problem for me as well.