|
Try this way.
CString strInteger(_T("302"));<br />
int iValue = _ttoi(strInteger);
i value will be 302
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
|
You have recieved several answers to your question and they all show you how to convert a string to integer. Take note that this is not type casting, it is conversion from one form to another. This is important because you could type cast a string to an integer value but the value would not be the value entered in the string. It would take the individule byes and assume they are parts of the final number you are seeking.
char str = "AB"; // 'A' = 0x41, 'B' = 0x42
short n = (short*)(str); // n = 0x4241 = 16961
If you are wondering about the reversal of the numbers durring the type casting, then you need to go look up big endian and little endian on the Web.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi guys !
In windows service code
I have following code in function void CServiceModule::Run()
CDatabase DB;
try
{
if( !DB.IsOpen() )
DB.Open("PrinterDB");
}
catch( CDBException* e )
{
char Buffer[256]="";
AfxMessageBox(e->m_strError);
}
DB.Close();
here PrinterDB is the name of my DSN pointing to an MDB file.
Now when I run it as normal executable it works properly.
but When I run it as service (from MMC start service) connect to DB fails.
Please help me...
|
|
|
|
|
|
this is a security related issue.
what rdbms u r connecting to?
what kind of authentication you used in ur dsn?
cheers..milton kb
|
|
|
|
|
I am connecting to Microsoft MS acess database (mdb file.) . It says
try
{
// My code
}
catch( CDBException* e )
{
::OutputDebugString("CDatabase incorrect");
char Buffer[256]="";
AfxMessageBox(e->m_strError);
}
Error
"Data source name not found and no default driver specified"
|
|
|
|
|
how can we use flex and bison with visual c++
any tutorial and documentation....
-- modified at 1:41 Thursday 15th June, 2006
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
actually i wanted to know how we can setup flex and bison with visual c++
because when i tried to compile lex.yy.c file with visual c++ it shows many errors not recognizing c operators 'exit','malloc','realloc','free'
|
|
|
|
|
It doesn't show how to use Bison with VC++, which is what the OP requested.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am using word automation to get the text in a word document however, i face problems when the document is already open. Is there a way (coding) to check if that document is open and if open, close it?
|
|
|
|
|
Try below code.
Word::_ApplicationPtr wdPtr;<br />
Word::_Application::get_Application( &wdPtr); <br />
if ( NULL == wdPtr ) wdPtr.CreateInstance(__uuidof(Word::Application)); <br />
<br />
for (int i=0; i<wdPtr->Documents->Count; i++) {<br />
Word::_DocumentPtr dPtr = wdPtr->Documents->Item(i);<br />
if ( dPtr->Name == "whatever you are looking for" )<br />
dPtr->Close(); <br />
}
cheers ..milton kb
|
|
|
|
|
Hi guys!!
Have a trouble with the dialog bar!! I created a dialogbar in my application!! But I can't put a bitmap on button on that dialogbar!! Who can show me how!? I thanks very much
|
|
|
|
|
See Here:[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
once a socket is bound to a port...say 2000...how can u check if its freed at the end of the application...is there a command u can use in the command prompt?if it is still bound can u free it from there?
|
|
|
|
|
shuchigo_jane wrote: once a socket is bound to a port...say 2000...how can u check if its freed at the end of the application.
Once you close the socket the port is automatically freed...So take care of closing of socket.
shuchigo_jane wrote: is there a command u can use in the command prompt?
you can check it while tring to bind to the specific port(i mean 2000) is free or not if it is free you can able to bind it.
shuchigo_jane wrote: if it is still bound can u free it from there?
You just can't because the port is available only if it is free and is free after closing the socket binded to that port or killing the application which uses that port.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
is aborting a VC++ app equivalent to killin it?or does it have to be executed till d end?
|
|
|
|
|
shuchigo_jane wrote: is aborting a VC++ app equivalent to killin it?or does it have to be executed till d end?
It terminates the execution forcefully whatever going on
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
what im trying to do is in a listbox when i left click my menu pops up and that allows me to open my other dialog below is the code to get the string i want
CString temp, temp1;
int nIndex = m_list.GetSelectionMark();
temp = m_list.GetItemText(nIndex, 0);
temp1 = m_sBaseFolder;
temp1 += "\\";
temp1 += temp;
i want to pass that string from one class to the other i just cant get it to pass everything ive tryed when my second dialog trys to open it errors so i dont know what im doing wrong. i just need a function that will return temp1.
ps. what is the right way to open a dialod from a menu?
-- modified at 0:23 Thursday 15th June, 2006
|
|
|
|
|
Create the pointer of sencond dialog in the first first dialog so that all the member varbales of seocnd dialog can be initialised from first dialog.
Now when you show get the string pass it to the member varibale of Second Dialog CString varibale and with the same object you can display the dialog.
For eg.
You have two dialogs
CFirstDialog and CSecondDialog and you are having CString varibale in Second Dialog class as m_frstDlgString
In first dialog IMplementation file write:
CSecondDialog *m_sDlg;
<br />
m_sDlg = new CSecondDialog();<br />
m_sDlg->m_frstDlgString = temp1;<br />
m_sDlg->DoModal();<br />
<br />
<br />
Cheers
"Peace of mind through Technology"
-- modified at 0:35 Thursday 15th June, 2006
|
|
|
|
|
You will have to declare a pointer of the first class in the header file of the second dialog(assuming you have a class associated to the dlg's).
Now when you are calling the second dialog do this :
CMySecondDlg *mySec=new CMySecondDlg();
mySec->oldPtr=this;
mysec->DoModal();
(Do not forget to include the header files)
Now if your string is defined as CString myString in the first class:
AfxMessageBox(oldPtr->myString);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
maybe it is some helpful to you
Main Class is CMain and one child dialog CLocal now you declare this code in child dialogCMain* m_Main = (CMain* )GetParent(); and ues m_Main->(variable)(function)... in main dialog
whitesky
|
|
|
|
|
Hi,
I have an old project at hand and I would like to add some new things to it and compile it into the release file with different name. For example, the old release file is named testing.exe, and I would like to change it to be testnew.exe. What do I need to change in the project to realize it? Is it the only to change project/property/linker/output file?
Thank you very much!
David
-- modified at 0:08 Thursday 15th June, 2006
|
|
|
|
|
David L.S. wrote: I have an old project at hand and I would like to add some new things to it and compile it into the release file with different name. For example, the old release file is named testing.exe, and I would like to change it to be testnew.exe. What do I need to change in the project to realize it?
Just Go into Linker settings of the Project Settings
and change the Output file as $(OutDir)/testnew.exe
Knock out 't' from can't,
You can if you think you can
|
|
|
|