|
Christian Graus wrote: use atoi to convert.
In that case, the string need to be in decimal representation, not in binary representation.
|
|
|
|
|
Shah Satish wrote: how to convert string to binary...
Take a look at strtol[^]. You can provide 2 as the basis and it will convert your string representing a binary into a long. Then you just perform logical operations on your long (&& for AND, || for OR, for XOR I don't remember what it was but you can make an OR and then invert the result with !).
|
|
|
|
|
Thank you dear..I got my solution.
|
|
|
|
|
Hi Shah,
Following routine should do the job:
int StrToBinary (LPCTSTR szString)
{
int nBit = 1;
int nResult = 0;
int i;
i = strlen (szString);
while (i > 0)
{
if (szString[--i] != '0')
nResult |= nBit;
nBit *= 2;
}
return nResult;
}
Good luck
William
|
|
|
|
|
Hi Wim..Thanks for your reply..
|
|
|
|
|
I am running 5 instances of an exe. every instance deals with same database. I know that i have to use CMutex for synchronization. but i dont know how to use it. niether MSDN provided a solid example. please tell me how to do it. Thanks in advance
Anil Jillella
|
|
|
|
|
Hi,
I think MSDN provides full documentation of API's and I think such support are not available for other Operating system.
The following link is from MSDN providing example program for CMutex usage
http://msdn2.microsoft.com/en-us/library/ms386471(VS.71).aspx[^]
There are lots of tutorial you can find if you google it.
Best Regards
Raj
|
|
|
|
|
Hi,
If you are using CMutex you should use Named Mutex as your problem is accross process boundary.
Best Regards
Raj
|
|
|
|
|
CMutex is a syncrhonisation object that is very close to CCriticalSection.
The only difference is that CMutex can be shared accross different processes.
At the startup of your application, initialize a new instance like that :
CMutex test(TRUE,_T("MyMutex"));
The name of the mutex is very important of course, it allows windows to link different mutex that have the same name.
Call Lock() to enter a critical section, if another thread has already entered this portion of code, then you thread will wait for the other one to leave the section before entering.
Call Unlock() when you are done with database calls
Tout programme dont la fiabilité dépend de l'homme n'est pas fiable
|
|
|
|
|
Would you please forward me a simple program that will overload << operator in C++?
|
|
|
|
|
pan_angel wrote: Would you please forward me a simple program that will overload << operator in C++
That would be only if we get PAID here .
And why do you need this? Read some books buddy. A good C++ book would be surely having an example for operator overloading and that would help you in developing the code in the time to come rather than seeking help from others each and every time.
You should atleast give it a GO!!!
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Look at his posts over the last few days. They are very generic. I think he's looking for homework answers.
__________________
Bob is my homeboy.
|
|
|
|
|
Interesting overloads of such operator are made in standard C++ ostream class and in MFC CArchive class (see Serialization topic, for learning purposes youcan also see MFC sources).
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.
|
|
|
|
|
|
Your question is a simple one that if you put any amount of time researching (or buying a book) you would find the answers. Stop asking us to write code for you and do your own homework.
__________________
Bob is my homeboy.
|
|
|
|
|
Hi
I have a dll file.But the interface is in dll also exist in oaidl.h file.Whenever i try to CreateInstance of the interface it recognise the .h file intreface.
How can i resolve ambiguity.
Can i use to namespace of dll file if yes please tell me how?
Thanx in advance.
|
|
|
|
|
I guess that you are talking of a COM-DLL and the #import directive.
In this case you can use the rename attribute. If the COM-DLL already provides a namespace the attribute rename-namespace may be useful, too.
Regards,
Tim
|
|
|
|
|
But sir
The main thing how can i know about the namespace the dll provide ?
|
|
|
|
|
If I remember correctly, the default namespace matches the name of the library.
Use the "OLE/COM Object Viewer" (you find it in the Tools menu of Visual Studio), browse to the according Type Library and open it. Somewhere you will find something like:
[
...
]
library SERVERLib
{
...
}
In this case SERVERLib will be the default namespace.
Regards,
Tim
|
|
|
|
|
hye,
i m making a project in which i have to display video in an edit box....
i have a DVR card but i want to make a separate aaplication using the functions of that card
can anybody tell me the procedure or steps of displaying the video in general.i mean not specific to any software......
pls give me some hints
looking 4 help
NT
|
|
|
|
|
You'd use DirectX to do this ( specifically DirectShow, which is now in the Platform SDK ). Plenty of articles on this on CP and elsewhere.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
actually i want to use functions of my DVR card
the link u suggested is an application
i dnt need code
i need articles which explains how to display video in VisualC++
i want to knw the steps nd functions which i shld include in my code for dispplaying video
looking 4 reply...........
NT
|
|
|
|
|
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
class Complex{
public:
Complex();
Complex(double);
Complex(double,double);
void write() const ;
bool operator==(const Complex& ) const ;
bool operator!=(const Complex& ) const ;
Complex operator-();
friend ostream& operator<<(ostream& out,Complex& c);
private:
double real;
double imag;
};
Complex::Complex(){
real=imag=0.0;
}
Complex::Complex(double re){
real=re;
imag=0.0;
}
Complex::Complex(double re,double im){
real=re;
imag=im;
}
void Complex::write() const {
cout<<real<<"+"<<imag<<'i'<<endl;
}
bool Complex::operator==(const Complex& u ) const {
if(real==u.real&&imag==u.imag)
return true;
else return false;
}
bool Complex::operator!=(const Complex& u ) const {
if(real!=u.real||imag!=u.imag)
return true;
else return false;
}
Complex Complex::operator-(){
real=-real;
imag=-imag;
}
ostream& operator<<(ostream& out,const Complex& c)
{
return out<<c.real<<"+"<<c.imag<<'i'<<endl;
}
int main(){
Complex c1(2.3,5.6);
Complex c2(1.4,2.5);
if(c1==c2) {
c1.write();
c2.write();
cout<<c1<<endl;
cout<<c2<<endl;
}
return 0;
}
I have declared :friend ostream& operator<<(ostream& out,Complex& c);
but why the error says:
cannot access private member declared in class 'Complex'?
|
|
|
|
|
Hi,
Your function declaration has different prototype,
one has const reference other is not const.
Best Regards
Raj
|
|
|
|