|
What happens if you retrieve the string into CString instead of _bstr_t ? Btw if you check out the string as a byte array, what do you get at the place of questionmarks? Can you maybe upload that text file somewhere for me so i can take a peak?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I can't use CString ... Not using MFC ..
Is there any subsitute of CString in Win32 ???
Thanks..
|
|
|
|
|
Hmm, am not sure...how about std:string ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Try outputting the string and check whether it is really some junk characters or you were just unable to view it properly.
You could do this.
MessageBox(0, (wchar_t*)bstrvariable, 0, 0);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That give some hope..When i use MessageBoxW it doesn't give "????" , rather that it give some junk character (Might be chinese which is not supported in messagebox).. Trying to print into notepad..
|
|
|
|
|
I believe the characters are encoded in the multi-byte character set.
So you should first extract the characters into a char array instead of wchar_t array or string variable instead of wstring variable or you can explicitly use CStringA instead of CString .
After getting it into the variable, convert the multi-byte characters into wide characters using the MultiByteToWideChar API.
Now use that in a MessageBoxW function.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I just did this to print data on file...
(char *)(wchar_t*)bstrString_Dest
And it's printing chinese character... That was just a blind try..how did it work..Can someone explain?
|
|
|
|
|
I did this...
bstrString_Dest = m_cpRecordsetSearch->Fields->GetItem("DestinationValue")->GetValue().bstrVal;
Extracted the character in char array..
strncpy(bstrString_Dest_Char,(char*)bstrString_Dest, sizeof(bstrString_Dest_Char));
Converted using MultiByteToWideChar..
TCHAR wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,
(wchar_t*)wsz, MAX_PATH);
Printed using Messagebox
MessageBoxW(0, (wchar_t*)wsz, 0, 0);
But same result
|
|
|
|
|
Use wchar_t instead of TCHAR
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
<quote>Use wchar_t instead of TCHAR
Changed it to this
wchar_t wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,wsz, MAX_PATH);
MessageBoxW(0, wsz, 0, 0);
and this..
wchar_t wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,(wchar_t*)wsz, MAX_PATH);
MessageBoxW(0, wsz, 0, 0);
But Same result...Gossh what am i doing wrong?
|
|
|
|
|
|
My final try.
Try CP_UTF8 instead of CP_ACP .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sadly that didn't work either.. Anyways thanks for your help..
|
|
|
|
|
MessageBox(0, (wchar_t*)bstrvariable, 0, 0);
I guess this is giving me right data...
How do i print this to file.. Notepad??
Thanks..
|
|
|
|
|
I need help with this code I can't seem to get it right please help.
#include<iostream>
#include<string>
using namespace std;
enum gameName{odd, even};
void displayRules();
gameName retrievePlay(int selection);
bool valdSelection(char selection);
void convertEnum(gameName odject);
gameName winningOdject(gameName play1, gameName play2);
void gameResult(gameName play1,gameName play2, int& winner);
void displayResults(int gCount, int wCount1, int wCount2);
int main ()
{
int selection;
int play1, play2;
int sum;
int gameCount;
int winCount1, winCount2;
int num[5];
int counter;
int gamewinner;
char response;
int selection1, selection2;
int gamePlay1;
int gamePlay2;
gameCount = 0;
winCount1 = 0;
winCount2 = 0;
displayRules();
cout << "Enter Y|y to play the game: ";
cin >> response;
cout << endl;
while ( response == 'Y' || response == 'y')
{
cout << "Player1 enter your choice: ";
cin >> selection1;
cout << endl;
cout << "player2 enter your choice: ";
cin >> selection2;
cout << endl;
if ( valdSelection(selection1) && valdSelection(selection2))
{
play1 = retrievePlay(selection1);
play2 = retrievePlay(selection2);
gameCount++;
gameResult(play1, play2, gamewinner);
if (gamewinner == 1)
winCount1++;
}
cout << "Enter Y | y to play the game: ";
cin >> response;
cout << endl;
}
displayResults(gameCount, winCount1, winCount2);
for ( counter = 0; counter < 5; counter++)
cin >> num[counter];
sum = sum + num[counter];
cout << endl;
return 0;
}
void displayRules();
{
cout << "Hi and welcome to the game Odds and Evens." << endl;
cout << "This is a game for one or two players." << endl;
cout << "The rules of the game are has follows:" << endl;
cout << "1. the players choise either Odds or Evens." << endl;
cout << "2. The players choise a number between 1 and 5." << endl;
<< "3. After player choise there number. " <<endl;
<< "The sum of the numbers either equal a odd number of an even number." << endl;
cout << "The winner is the player that has the right choise." << endl;
}
gameName winningOdject(gameName play1, gameName play2, odd, even)
{
if ((play1 == odd)&& (play2 ==even)||
(play2 == odd) && (play1 == even));
return odd;
if (( play1 == even) && (play2 == even) ||
( play2 == even) && (play1 == even));
return even;
}
void gameResult(gameName play1, gameName play2 ,int& winner)
{
gameName winnerOdject;
winnerOdject = winningOdject(play1, play2);
cout << "Player1 selected: ";
convertEnum(play1);
cout << " and Player2 selected: ";
convertEnum(play2);
cout << " ";
if( play1 == winnerOdject)
winner = 1;
if (play2 == winnerOdject)
winner = 2;
cout << "Player " << winner << " wins this game." <<endl;
}
void displayResults(int gCount, int wCount1, int wCount2)
{
cout << "The total number of games: " << gCount << endl;
cout << "The number of games won by player1: " << wCount1 << endl;
cout << "The number of games won by player2: " << wCount2 << endl;
}</pre>
|
|
|
|
|
so, what is the problem ? does it compile ? does it give wrong answers ? having problem with the logic ?
for example :
if (gamewinner == 1)
winCount1++;
so what happens with player 2 ? doesn't she ever win ?
This signature was proudly tested on animals.
|
|
|
|
|
The answer to the question is that it dose not complier. I have 3 errors like
'gameResult' : cannot convert parameter 1 from 'int' to 'gameName'.
|
|
|
|
|
You should do like
(gameName)yourIntVariable
But should always use the right ENUM value.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I'm not sure I understand what you are saying. I'm confused!
|
|
|
|
|
You are trying to pass an int to argument that takes your ENUM, i.e gamename.
Ok Just post the exact line where you get the error message.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
here is the lines
void gameResult( gameName play1, gameName play2, int& winner)
{
gameName winnerOdject;
winnerOdject = winningOdject(play1, play2);
// outputs each players choise
cout << "Player1 selected: ";
convertEnum(play1);
cout << " and Player2 selected: ";
convertEnum(play2);
cout << " ";
// Decide the winner
if( play1 == winnerOdject)
winner = 1;
if (play2 == winnerOdject)
winner = 2;
cout << "Player " << winner << " wins this game." <<endl;
}
|
|
|
|
|
No I wanted the exact line. I mean when you click on the error, it takes you to the line right? that one. Anyway tell me one thing,
gameName winningOdject(gameName play1, gameName play2, odd, even)
{
}
What's the type of "odd" & "even" here?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I change allot of the code so I will post it again still need help I have to turn it in at midnight tonight.
<#include<iostream>>
using namespace std;
enum game{odd, even};
void displayRules();
game retrievePlay(int selection);
bool valdSelection(char selection);
convertEnum(game odject);
game winningOdject(game play1, game play2);
void gameResult(game play1, game play2, int& winner);
void displayResults(int gCount, int wCount1, int wCount2);
int main ()
{
int selection;
int play1, play2;
int sum;
int gameCount;
int winCount1, winCount2;
int num[5];
int counter;
int gamewinner;
char response;
int selection1, selection2;
int gamePlay1;
int gamePlay2;
gameCount = 0;
winCount1 = 0;
winCount2 = 0;
displayRules();
cout << "Enter Y|y to play the game: ";
cin >> response;
while ( response == 'Y' || response == 'y')
{
cout << "Player1 enter your choice: ";
cin >> selection1;
cout << endl;
cout << "player2 enter your choice: ";
cin >> selection2;
cout << endl;
if ( valdSelection(selection1) && valdSelection(selection2))
{
play1 = retrievePlay(selection1);
play2 = retrievePlay(selection2);
gameCount++;
gameResult(play1, play2, gamewinner);
if (gamewinner == 1)
winCount1++;
else (gamewinner ==2);
winCount2++;
}
cout << "Enter Y | y to play the game: ";
cin >> response;
cout << endl;
}
displayResults(gameCount, winCount1, winCount2);
for ( counter = 0; counter < 5; counter++)
cin >> num[counter];
sum = sum + num[counter];
cout << endl;
return 0;
}
void displayRules();
{
cout << "Hi and welcome to the game Odds and Evens." << endl;
cout << "This is a game for one or two players." << endl;
cout << "The rules of the game are has follows:" << endl;
cout << "1. the players choise either Odds or Evens." << endl;
cout << "2. The players choise a number between 1 and 5." << endl;
<< "3. After player choise there number. " <<endl;
<< "The sum of the numbers either equal a odd number of an even number." << endl;
cout << "The winner is the player that has the right choise." << endl;
}
game winningOdject(game play1, game play2)
{
if ((play1 == odd)&& (play2 ==even)||
(play2 == odd) && (play1 == even));
return odd;
if (( play1 == even) && (play2 == even) ||
( play2 == even) && (play1 == even));
return even;
}
void gameResult( game play1, game play2, int& winner)
{
game winnerOdject;
winnerOdject = winningOdject(play1, play2);
cout << "Player1 selected: ";
convertEnum(play1);
cout << " and Player2 selected: ";
convertEnum(play2);
cout << " ";
if( play1 == winnerOdject)
winner = play1;
if (play2 == winnerOdject)
winner = play2;
cout << "Player " << winner << " wins this game." <<endl;
}
void displayResults(int gCount, int wCount1, int wCount2)
{
cout << "The total number of games: " << gCount << endl;
cout << "The number of games won by player1: " << wCount1 << endl;
cout << "The number of games won by player2: " << wCount2 << endl;
}:confused:/pre>
|
|
|
|
|
How to skin scrollbar of all controls in Application?
(TreeCtrl, ListCtrl, ComboBox)
|
|
|
|
|
Do you maybe need this[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|