|
I am on Unix and wanted to see an int on the screen so I did
int i = 9;
cout << '(' << i <<')';
But I dont see the value of i , just (). What do I need to do to i to make cout show it? I thought cout knew how to interpret the arg...
thanks,
ns
|
|
|
|
|
Try
int i = 9;
cout << '(';
cout << i;
cout << ')';
Another solution would be:
int i = 9;
printf("(%d)", i);
Hope this helps
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
ns asked a good question... isn't there any way to write this in a same cout line? that seem to be strange if we could.
Of course, i think cout << '(' << ((int) i) << ')'; would be better, but i didn't test it yet.
TOXCCT alias Nicolas C.
|
|
|
|
|
There's nothing wrong with your code, and it works just fine on my system. Are you sure you used exactly the same code as in your message in your program?
|
|
|
|
|
Oh. I found what I was doing wrong. I wasnt doing exactly what I posted. WHat I did is essentially tried to display char s
where I had set s = 0;
That was dumb but I didnt realise that it woas not going to show me a '0'.....
So I appreciate you taking the trouble to test it out...
thanks,
ns
|
|
|
|
|
Can I have any examples ??
Also, I want to ask how can I open two dialog box at the same time when running an application??
thx very much!!
|
|
|
|
|
|
I want to ask regarding the masking in Visual C++ . In my project i need to control 9 devices at the same time by using one parallel port interfacing,which is 3 fan, 3lamp, and 3 switch. So, how should i do,should i use the masking way and what is its source code.
|
|
|
|
|
Tan Sen Nee wrote:
...and what is its source code.
Its source code is whatever you write.
I'll assume you have a way of setting the parallel port to a word (16 bits) of your choice.
struct
{
WORD wLamp1 : 1;
WORD wLamp2 : 1;
WORD wLamp3 : 1;
WORD wGap : 4;
WORD wFan1 : 1;
etc...
} MyHardware;
MyHardware.wLamp2 = 1;
SetParallelPortFunctionOfSomeKind ((WORD *)&MyHardware);
MyHardware.wLamp2 = 0;
SetParallelPortFunctionOfSomeKind ((WORD *)&MyHardware);
Search your C(++) manual for "bit fields".
Iain.
|
|
|
|
|
hello,
I want to do pci detection in an MFC application. I wrote inline assembly codes to do it.
...
int a=0;
int c=0;
__asm
{
mov ax, 0xB101;
int 0x1A;
mov a,eax;
mov c, ecx;
}
...
The program was compiled. while running, when this function is called, it gives an error message as "The instruction at '0x....' referenced memory at '0xffffffff'. The memory could not be 'read'." and closes.
I could not find any documentation for pci bios functions on vc++. I need to do it in vc++; not in dos, or dos under windows.
It's not only the detection, but also I want to read from the pci config. space later on.
i would be very happy to get some help.
thanks...
|
|
|
|
|
caykahve wrote:
I want to do pci detection in an MFC application. I wrote inline assembly codes to do it.
In short, you can't.
MFC apps run in user mode. This is a lower privilege mode, and the OS stops you from accessing
hardware, other programs memory, etc.
You will need to write a device driver to do your hardware level work, and communicate with
it from your MFC app.
Neither of these steps are going to fit in a quick answer...
Iain.
|
|
|
|
|
How can i redarw controls(with changed co ordinates) in a MFC Application, once i have detected that resolution has changed??
|
|
|
|
|
Call the RedrawWindow function on the top level window with atleast the parameters RDW_INVALIDATE and RDW_ALLCHILDREN. It will step through all child windows itself and make sure every child window gets redrawn. Then again, if the resolution has changed don't all windows get a WM_PAINT message automatically?
|
|
|
|
|
thanx Luuk,
But it doesn't seem to work. Can u elaborate on it by an example.
|
|
|
|
|
Sure, it's quite simple:
LRESULT CMyFrameWnd::OnDisplayChange(WPARAM wParam, LPARAM lParam)
{
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN | RDW_UPDATENOW);
return CFrameWnd::OnDisplayChange(wParam, lParam);
}
This should do the trick, if it doesn't then I suppose something else is going on.
|
|
|
|
|
Hi!
I have a problem with saving packets to a file. A packet loss occur at time XXYY. Then I will name open a file name it to XXYY, store some packets, and then close the file. Next time a packet is losses I will open a new file with the name as time HHMM. But it will not work. It cannot open the file.
Does anyone know how to do it???
Im store the time in a char buffer, and then I copy it into char Filename[20].
My code:
void WriteToFile()
{
strcpy(Filename, time[line])
ofstream outFile;
outFile.open(Filename, ios::out);
if(!outFile){cout << "cant open file"<
|
|
|
|
|
Add some breakpoints. Determine why the program cannot create the file.
Kuphryn
|
|
|
|
|
Ouuuuch! Trying to check statically declared ofstream for errors by if (!outfile) ?????
Use if (outfile.fail()) { ... } )
Robert-Antonio
"I launched Norton Commander and saw, drive C: on the left,
drive C: on the right...Damn, why I need two drives C:??? So I formatted one..."
|
|
|
|
|
Hi
Is it possible to add toolbar and statusbar to an dialogbased application?
WBR
Edi
|
|
|
|
|
|
Hi everyone,
I have class A in DLL with virtual function in it, like this...
<br />
class __declspec(dllexport) A {<br />
public:<br />
vitual void Foo() { some code; };<br />
}<br />
And there is derived class B in the same DLL...
<br />
class __declspec(dllexport) B : public A {<br />
public:<br />
vitual void Foo() { some code; };<br />
}<br />
Now, when I compile it, everything's ok. But I also have a console app where I create instances of class B from DLL. Of course I link .lib file with it. But when I try to compile this app I have an error from linker.
error LNK2001: unresolved external symbol "public: virtual void __thiscall B::Foo(void)"
Does anybody have any ideas how to solve this matter?
P.S. When I check EXPORTS from my DLL with dumpbin.exe, I can see both methods there. So, ?FooA@A@@ and ?FooA@B@@ are there. But linker's looking for ?Foo@B@@, without "A" at the end of the method name and obviously can't find it.
Any idea what's wrong?
Thanks in advance,
va'Lery
|
|
|
|
|
This is, I admit, a guess.
When included by the application, is it marked __declspec(dllimport) ?
You should normally write your header as follows:
#ifdef BUILDING_DLL
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif // def BUILDING_DLL
class MYDLL_API A { };
class MYDLL_API B : public A { }; and define BUILDING_DLL in the DLL project.
I'm not sure how well __declspec(dllexport) interacts with in-line member function definitions.
|
|
|
|
|
Thanks Mike,
I surely use mechanics that you described, so in my app I have __declspec(dllimport).
Concerning inline function, if I remove "virtual" when everything's fine. But that's not what I need. I have to use virtual function there.
va'Lery
|
|
|
|
|
hi.
Plz tell me how can i place a GIF file on a Dialog ,, and in a rich edit control
thanx
|
|
|
|
|
Hi!
GIF and JPEG files cannot be used in your application because they are copyrighted by their developpers.
As a solution you may put a webbrowser control and show the gif file in it ( you put it in a html file and it is done).
I hope this helps!
Well... I am a beginner ...
|
|
|
|