|
You can ignore this off topic discussion with cpallini...
It's a running joke about CString's overly misused GetBuffer() method
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
chrs[1] = _T("\0"); // must be NULL terminated!
I get this error: " error C2440: '=' : cannot convert from 'const char [2]' to 'TCHAR'"
any ideas why?
A C++ programming language novice, but striving to learn
|
|
|
|
|
I used the wrong quotes, sorry!
That should be single quotes for a single character...
chrs[1] = _T('\0'); // must be NULL terminated!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I'm getting a compiler error C1001; even after commenting out all the new code in the function. I tried shutting down the switches as help suggest. That doesn't work either. Any ideas?
A C++ programming language novice, but striving to learn
|
|
|
|
|
What's the error and what's the code involved?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I solved the problem by deleting the debug obj file previously created. works now!
A C++ programming language novice, but striving to learn
|
|
|
|
|
I tried that. Here's my code:
TCHAR chr;
int ch = 0;
chr = str.GetAt(0);
ch += atoi(chr);// ERROR HERE: when I try to convert it to int using atoi(chr)
I get this error: "Error 1 error C2664: 'atoi' : cannot convert parameter 1 from 'TCHAR' to 'const char *' c:\users\larry a mills sr\documents\visual studio 2008\projects\logit\logit\editlog.cpp"
A C++ programming language novice, but striving to learn
|
|
|
|
|
atoi() takes a const char * as an argument, not a TCHAR.
What are you trying to do? Convert the TCHAR you extracted to an int?
If so, you should be using generic text mapped functions, not functions like
atoi() that only work with one character type.
Generic text mapped functions will work for Unicode or non-Unicode builds.
In a Unicode build, a TCHAR is a wchar_t
In a non-Unicode build, a TCHAR is a char
Generic-Text Mappings in Tchar.h[^]
CString is also a generic text class by the way - it's internal character type is based on the Unicode build setting.
Also, you need to pass the correct type of argument to functions.
Maybe something like this:
TCHAR chrs[2];
int ch = 0;
chrs[0] = str.GetAt(0);
chrs[1] = _T("\0");
ch += _tstoi(chrs);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
You learn new stuff everyday if you just try.!
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: You learn new stuff everyday
It will be a sad day when I don't
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark, what about
int ch = str.GetAt(0) - _T('0');
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Can anyone help me get on the right track with this program. I am having a hell of a time with this. I have to use De Morgans Law to show the original expression and the new expression:
a) ! ( x < 5 ) && ! ( y >= 7)
b) ! ( a == b ) || ! ( g != 5)
c) ! ( (x <= 8 ) && ( y > 4 ) )
d) ! ( (i > 4 ) || ( j <= 6 ) )
I know how to put it into De Morgans Law I just don't understand how to put it into a source code in C++
|
|
|
|
|
Please look at my code given below.
I am trying to download the one folder from one site using FTP
I have written the code for Download directory which calls itself recursivly and I am closing and opening the connetion eac time.
But the problem is it downloads only first two folders completly but it could not find the third folder or file though it is there.
FindNextFile function returns false after downloading second folder.
Please help me for this..
Here is the code for Download Directory
BOOL CFTPUpDwnldManager::DownloadDirectory(CString strSrcDirPth,
CString strTrgfDirPath)
{
BOOL bRetVal = FALSE;
theApp.WriteFTPlog("Src Directory:" + strSrcDirPth);
theApp.WriteFTPlog("Trg Directory:" + strTrgfDirPath);
if(strSrcDirPth.IsEmpty() || strTrgfDirPath.IsEmpty())
{
return bRetVal;
}
// assum that *.* is not apped in src and trg path
CString strSrcDirPth1 = strSrcDirPth;
int index = strSrcDirPth1.ReverseFind('//');
int indx= strSrcDirPth1.GetLength() - index;
CString strSrcDirPth2 = strSrcDirPth1.Right(indx);
CString RemoteDir=strSrcDirPth;
CString dirpath=strTrgfDirPath + strSrcDirPth2;
CreateDirectory(dirpath,NULL);
CString LocalDir = dirpath;
CFTPUpDwnldManager *pCFTPUpDMngr = (CFTPUpDwnldManager *)lParam;
if(NULL == pCFTPUpDMngr)
{
return bRetVal;
}
CFTPManager *pFTPManager = (CFTPManager *)lParam;
if(NULL == pFTPManager)
{
return bRetVal;
}
CNSInternetSession* pInternetSession = pFTPManager->GetInternetSessionPtr();
if(NULL == pInternetSession)
{
return bRetVal;
}
pCFTPUpDMngr->CloseFTPConnection();
if(-1 == pCFTPUpDMngr->GetFTPConnection())
{
return bRetVal;
}
CFtpFileFind fileFind(pFtpConnection,0);
CString strFindFilePath = RemoteDir + "/*.*";
BOOL bContinue = fileFind.FindFile(strFindFilePath) ;
DWORD dw = GetLastError();
if (!bContinue)
{
// the directory is empty; just close up and return.
fileFind.Close();
return bRetVal;
}
while (bContinue)
{
bContinue = fileFind.FindNextFile();
DWORD dw = GetLastError();
CString tempDirName = fileFind.GetFileName();
CString tempDirPath = fileFind.GetFilePath();
CString tempFileUrl= fileFind.GetFileURL();
if(fileFind.IsDots())
{
continue;
}
if (fileFind.IsDirectory())
{
CString NewSrcDir = RemoteDir + "/" + tempDirName;
//CString NewTrgDIr = LocalDir + "/" + tempDirName;
CString NewTrgDir = LocalDir;
DownloadDirectory( NewSrcDir ,NewTrgDir );
}
else
{
DownloadFile( RemoteDir + "/" + tempDirName ,LocalDir + "/" + tempDirName );
}
}
bRetVal = TRUE;
return bRetVal;
}
|
|
|
|
|
|
hi all.
view does not repaint properly when the main frame window is resized
thanks in advance.
|
|
|
|
|
v.j wrote: view does not repaint properly when the main frame window is resized
Thanks for letting us know.
By the way, how did you come up with such an elaborate subject line?
|
|
|
|
|
v.j wrote: thanks in advance.
You're welcome, in retrospect.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use of Invalidate.
|
|
|
|
|
The messages generated by the system should handle that.
Please don't reinforce this poor posting behavior!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok.
|
|
|
|
|
hello everyone;
please tell me "How to add button to CListCtrl ?"
thanks in advance.
|
|
|
|
|
hi,
why r u post ur thread in my thread ,
please post it in new thread for relevant answers.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi all,
I am trying to initialize an object using it's constructor, but the members of the object are just not getting initialized.I will just explaining it to you with some coding so that you can understand my issue in a better way.
I have a base class ,say CBase and I am deriving a class from it ,say Derived.
<br />
Base<br />
----<br />
class CBase<br />
{<br />
int nBmember1;<br />
int nBmember2;<br />
<br />
public:<br />
CBase(int nBmember1,int nTempMember):nBmember1(nBmember1),nBmember2(nTempMember){}<br />
<br />
<br />
};<br />
<br />
Derived<br />
-------<br />
class CDerived :public CBase<br />
{<br />
int nDmember1;<br />
public:<br />
CDerived(int nBmember1,int nTempMember,int nTempMember2):CBase(nBmember1,nTempMember),nDmember1(nTempMember){}<br />
<br />
};<br />
<br />
int main()<br />
{<br />
CDerived *DerivedObj= new CDerived(25,50,75);<br />
}<br />
<br />
While creating an object passing these parameters ,It goes to the derived class constructor,the derived class constructor in turn calls the Base class constructor with their respective arguments.But these values are not being assigned to the members of the class.
while I access the DerivedObj , it has some junk value for its members..
I don't have any clue on why the object is not getting initialized with the correct values? Have anyone of you come across an issue like this?
Please help....
|
|
|
|
|
cydd wrote: nBmember1(nBmember1),
your formal parameter and member variable are having same name in the base class,
If you follow naming conventions like "m_" prefix for member variable, this type of programming errors can be avoided.
cydd wrote: (int nBmember1,int nTempMember,int nTempMember2):CBase(nBmember1,nTempMember),nDmember1(nTempMember){}
nTempMember2 is ununsed. always compile with highest warning level and don't ignore warnings, i prefer consider warning as error. unreferenced variable is easily caught by compiler.
modified on Saturday, March 8, 2008 6:06 AM
|
|
|
|
|
Thanks for ur response Rajkumar.
I appreciate ur suggestion.
However I tried using different names for the formal parameters, it's not working.
The warning level is 4 which is the maximum ..
But it doesnt show any kind of warning for this.
One more thing,I have used pragma pack(1) in the header file. if this could help you in assisting me.
Thanks
|
|
|
|