|
I've rebuilt the soloution. Then also the same problem persists. What to do?
modified on Friday, May 23, 2008 6:00 AM
|
|
|
|
|
Dear All,
I need to implement STRPTIME function in the Windows Mobile.I downloaded the wcelibcex-1.0 library as it was posted here.But it couldnot be run on Windows Mobile 5.0.Please help me to find a soution.This stands same for the gmtime() function and ctime.
|
|
|
|
|
Please have a look at this link: OpenTimeCE: time_t for Windows CE[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Is strftime() same as strptime(); or is there any difference?
|
|
|
|
|
Have you checked the documentation?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
ya but didn't find any details....
|
|
|
|
|
Arun John wrote: ya but didn't find any details....
Didn't find anything in the documentation? That's weird. Have you tried executing both the functions with same inputs and compared the results?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I found from documents that the strptime is derived from strftime...
But they have not given any implementations for strptime...
Please get me some tips...
|
|
|
|
|
Arun John wrote: But they have not given any implementations for strptime...
No implementation is given?!
The only strptime() I know of is from the OpenGroup[^]. And their documentation page for strptime()[^] has description about the function and an example too.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Can someone tell me how can I set background color of other application for which I donot have code.
Thanks
|
|
|
|
|
You must be get a hdc to other programs.
|
|
|
|
|
|
It depends to your work you can use of Enumchldwindow or use of FindWidow after you get a hwnd you can use of HDC hdc::GetDC(hwnd);
|
|
|
|
|
Hi,
I have recently started learning C++, having come from a mainly Java/PHP background. I am implementing a Poker library, which is something I do in each new language I learn, as porting the code seems a good way to learn syntax of languages. I have a class for data about single cards in the library:
Card.h
class Card
{
..snip..
const static int CLUBS = 0;
const static int DIAMONDS = 1;
const static int HEARTS = 2;
const static int SPADES = 3;
..snip..
public:
..snip..
string toString();
int charsToIndex(char rank, char suit);
};
Card.cpp
string Card::toString()
{
string s("");
s += getRankChar(getRank());
switch (getSuit())
{
case HEARTS: s+='h'; break;
case DIAMONDS: s+='d'; break;
case CLUBS: s+='c'; break;
case SPADES: s+='s'; break;
}
return s;
}
This code compiles and works fine, and passes all the unit tests I have implemented. However when I try to do the "reverse" of this action, I get a number of compiler errors:
Card.cpp
int charsToIndex(char rank, char suit)
{
int r = -1;
switch (rank) {
case '2': r = TWO; break;
case '3': r = THREE; break;
..snip..
}
int s = -1;
switch (suit) {
case 'h': s = HEARTS; break;
case 'd': s = DIAMONDS; break;
..snip..
}
}
The errors are "card.cpp(155) : error C2065: 'TWO' : undeclared identifier", repeated for each time I have used a constant within the charsToIndex function. I can't work out whether I have missed something stupid, or there's something about scope in C++ I don't quite understand.
Thanks in advance for any assistance.
|
|
|
|
|
You need the class id.
<br />
int Card::charsToIndex(char rank, char suit)<br />
{ <br />
..snip.. <br />
}<br />
|
|
|
|
|
may you add these lines before class Card
#define TWO "TWO"
#define THREE "THREE"
I hope it works.
|
|
|
|
|
From your code snipet it is not clear whether you declared TWO in the first place.
Also, allow me to give you a couple of suggestions: your code really looks like Java, and that is not a good way to write C++. I suggest you find a good C++ book, like Accelerated C++[^] and start from there.
Good luck
|
|
|
|
|
Replace this:
faceninja wrote: const static int CLUBS = 0;
const static int DIAMONDS = 1;
const static int HEARTS = 2;
const static int SPADES = 3;
with this:
enum Suit_t
{
CLUBS,
DIAMONDS,
HEARTS,
SPADES
};
Next replace all references to suit, such as underlined below, with Suit_t . ie. This:
int charsToIndex(char rank, char suit);
Should look like this:
int charsToIndex(char rank, Suit_t suit);
Steve
|
|
|
|
|
Thanks for all the assistance. As far as compiling goes, changing the function declaration to "int Card::charsToIndex(char rank, char suit)" makes it compile and run fine.
Thanks for the advice on how to make the code better C++ as well. Having come from a Java backgroud, I'm sure it's going to take me a while to get used to all the nuances of the language
|
|
|
|
|
hi
i have this function:
int CBmpDlgDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CBitmapDialog::OnCreate(lpCreateStruct) == -1)
return -1;
CString path;
if (vbGetCommandLine()!=" ")
{
if (vbGetCommandLine().Left(1)==CString(char(34)) && vbGetCommandLine().Right(1)==CString(char(34)))
{
path = vbGetCommandLine().Mid(2-1, (vbGetCommandLine().GetLength()-2));
}
else
{
path = vbGetCommandLine();
}
}
CFile f;
f.Open(path, CFile::modeRead);
CArchive ar(&f, CArchive::load);
ar >> m_EDIT1 >> m_EDIT2 ;
ar.Close();
f.Close();
return 0;
}
where the vbGetCommandLine() func is as follows:
CString vbGetCommandLine()
{
CString CommandLine;
for (int i=1; i<__argc; i++) {
if (i!=1) CommandLine += " ";
bool flSpace = strchr(__argv[i],' ') ? true : false;
if (flSpace) CommandLine += '"';
CommandLine += __argv[i];
if (flSpace) CommandLine += '"';
}
return CommandLine;
}
the main idea here is: after saving the file with any data it contains....
when i double click it ...it should open ..first by checking the path of the file then open that file.
ok..my question is ...in "OnCreate()" . exactly in f.open()...if i specified the path like "abc.ccc" it works
but when i put open(path)it wont.
although i checked the path value by amessage box and it showed me that i had the correct path ...this is driving me crazy....
so pleease i would be thankful for any kind of help
|
|
|
|
|
what you are doing in vbGetCommandLine() you are trying to form a single string while the command line is already managed to separate the parameters to separate buffers (argument vectors __argv) and you are trying to bound with quotes if a single parameter has space, do you know if the parameter has space it is split into individual __argv element. These should be taken care when executing the application.
lahom wrote: the main idea here is: after saving the file with any data it contains....
when i double click it ...it should open ..first by checking the path of the file then open that file.
if you want to get the file path, just take the first argument, better is to parse the parameters for flags,
Since you are using MFC, you can use CWinApp::ParseCommandLine, in the application InitInstance do the following,
BOOL <yourappclass>::InitInstance()
{
....
CWinApp::InitInstance();
....
<big>CCommandLineInfo cmdinfo;
ParseCommandLine(cmdinfo);</big>
CBmpDlgDlg dlg;
<big>dlg.m_strFileName = cmdinfo.m_strFileName; </big>
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
.....
and in the InitDialog of your dialog class open the file,
BOOL CBmpDlgDlg ::OnInitDialog()
{
CDialog::OnInitDialog();
....
CFile f;
f.Open(<big>m_strFileName</big>, CFile::modeRead);
CArchive ar(&f, CArchive::load);
.....
|
|
|
|
|
thanks for ur reply
Rajkumar R wrote: // set the file name to the member of your dialog class so that in the InitDialog create the file
what do u mean by m_strFileName
|
|
|
|
|
Obvious, declare a member variable for your Dialog class,
class CBmpDlgDlg: public CDialog
{
public:
CString m_strFileName;
|
|
|
|
|
ok
it works ..but when i put
CFile f;
f.Open(m_strFileName, CFile::modeRead);
CArchive ar(&f, CArchive::load);
in OnCreate() not onInitDialog() ...
but there is something.... the file i saved earlier opens fine...but
i cant run the program now it shows me a debug assertion failed..
what is wrong now
|
|
|
|