|
|
i need to write a c++ code that will convert the given postfix expression of the form
#1#2 && #3! #4#5 || ||
(with no spaces between))
to infix form
where
!
&&
and || aer the expressions used and its of the bbolean form only,
can someone ikndly help me in solving this!
ranjani
|
|
|
|
|
Converting from/to prefix, infix, and postfix, is easily accomplished using a stack data structure.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I'm trying to load some JPEGS onto a window but with no success...I have done this in the past with the same code and it worked as long as I declared a LPPICTURE global...in this case I need multiple pics to be loaded and displayed so I created a class with a linked list to load them all into
Here are some the functions:
class cPictureList
{
public:
class cPictureListElement
{
public:
IPicture *pPicture;
long hmWidth;
long hmHeight;
cPictureListElement()
{
pPicture = NULL;
hmWidth = 0;
hmHeight = 0;
}
private:
cPictureListElement *pNextPicture;
friend class cPictureList;
};
public:
cPictureListElement *pFirstPicture;
cPictureList()
{
pFirstPicture = NULL;
}
void Enter (char*);
void LoadCovers (long);
void LoadGalleryPic (char*, LPPICTURE);
void DisplayPictures (HWND, HDC, RECT);
};
void cPictureList::Enter(char *szFileName)
{
if ( pFirstPicture == NULL )
{
cPictureListElement *pNewPicture;
pNewPicture = new cPictureListElement;
LoadGalleryPic(szFileName, pNewPicture->pPicture);
pFirstPicture = pNewPicture;
pNewPicture->pNextPicture = NULL;
return;
}
cPictureListElement *pBeforePicture, *pAfterPicture;
pBeforePicture = pFirstPicture;
pAfterPicture = pFirstPicture;
while ( pAfterPicture != NULL )
{
pBeforePicture = pAfterPicture;
pAfterPicture = pAfterPicture->pNextPicture;
}
cPictureListElement *pNewPicture;
pNewPicture = new cPictureListElement;
LoadGalleryPic(szFileName, pNewPicture->pPicture);
pBeforePicture->pNextPicture = pNewPicture;
pNewPicture->pNextPicture = NULL;
}
void cPictureList::LoadGalleryPic(char *szFile, IPicture *gpPic)
{
HANDLE hFile = CreateFile(szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
DWORD dwFileSize = GetFileSize(hFile, NULL);
LPVOID pvData = NULL;
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
pvData = GlobalLock(hGlobal);
DWORD dwBytesRead = 0;
BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
GlobalUnlock(hGlobal);
CloseHandle(hFile);
if ( bRead == FALSE )
return;
LPSTREAM pstm = NULL;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID *) &gpPic);
pstm->Release();
}
void cPictureList::DisplayPictures(HWND hwnd, HDC hdc, RECT rc)
{
cPictureListElement *pDisplay;
pDisplay = pFirstPicture;
while ( pDisplay != NULL )
{
long hmHeight;
long hmWidth;
if ( pDisplay->pPicture != NULL )
{
pDisplay->pPicture->get_Width(&hmWidth);
pDisplay->pPicture->get_Height(&hmHeight);
}
else
MessageBox(NULL, "Picture is NULL", NULL, MB_OK);
pDisplay = pDisplay->pNextPicture;
}
}
In the function LoadGalleryPic gpPic is not NULL (I have tested this) and OleLoadPicture returns S_OK. The problem is in DisplayPictures...My test always gives me the messagebox saying the picture is NULL. I can only get it to work if gpPic is declared global and is not passed as a parameter to LoadGalleryPic. Any insight?
|
|
|
|
|
What does this syntax mean and how may I convert it to NASM?
leal (%eax,%eax),%edx
movw (%eax,edx),%ax
...Anybody?
Thanks.
B.
|
|
|
|
|
(Note: I may be a little rusty):
The full syntax for memory references in AT&T syntax is:
displacement(base,index,scale)
The above syntax translates to (in Intel syntax):
[base+(index*scale)+disp]
Most parts are optional; e.g. scale defaults to 1, displacement defaults to 0.
The l , w , and b suffixes used in AT&T syntax instructions translate to the dword , word , and byte keywords in Intel syntax (respectively).
Also, Intel syntax uses a reverse order of oprands.
So, in leal (%eax,%eax),%edx , you've got a lea instruction that's operating on longwords (dwords), is referencing a memory address eax + eax , and stores the result in edx . In Intel syntax, that's:
lea dword edx,[eax+eax]
(the dword can probably be omitted).
- Mike
|
|
|
|
|
I need to collect data from handphone using Infrared. The data in handphone or SIM card includes some Asian Characters which are supported by some phones. The character set that support Asian characters includes UTF-8 and UCS2. I collect UTF-8 formatted data from phone, and store them in a database, later i need to convert these UTF-8 formatted data to UCS2 data and send to a phone which support UCS2. Could you help me with this conversion between UTF-8 and UCS2?
Send me an email or reply this message. thanks
Regards
World on the way
|
|
|
|
|
MultiByteToWideChar
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks for your instruction. I will try it.
Regards
World on the way
|
|
|
|
|
i know in vb i can let programme continue to run when some errors occuring with the statement "On Error Resume Next".
how can i reach the same result in vc++?
thans!
Habbit--Beginner In MFC
|
|
|
|
|
VC++ does not have a catch-all error handling system. The closest you are going to get is by using a try/catch block. Using that, if an exception is thrown, you can choose to ignore it.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
thanks
Habbit--Beginner In MFC
|
|
|
|
|
catch-all is:
try
{
//code
}
catch(...)//3 dots
{
}
includeh10
|
|
|
|
|
I understand that, but not all error conditions throw an exception.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi there,
I have a CScrollView based view window. Whenever the scrollbar is clicked, it seems windows automatically copies a portion of the window towards the appropriate direction, to "help" in scrolling. Then my OnDraw() is done on top.
Anyone know a way to disable this?
Thanks,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
The behavior you are describing is what CScrollView was designed to do.
Why would you want to disable this behavior?
May be the following will help you figure out what the problem is:
When you click the scrollbar in a CSrollView based window it is scrolled automaticaly for you and DC origin is changed to the new possition. You then receive a WM_PAINT message (OnDraw()) to update (draw) the invalid portion of the window.
Before scroll:
origin of DC and Window -> (0,0) +-------------------+
| |
| |
| |
| |
(0, 100) +-------------------+
After scroll:
origin of DC -> (0,-N) +-------------------+
| |
origin of window -> (0, 0) +-------------------+ <- DC (0, N)
| |
| |
DC -> (0, 100) |-------------------|
| Invalid rect. | <- needs redrawing
window -> (0, 100) +-------------------+ <- DC (0, 100 + N)
If you do any drawing to the window outside of OnDraw() then you will need get the origin of the drawing DC so that you know where to draw. I usualy just use the scroll positions:
Origin.x = -GetScrollPos(SB_HORZ);
Origin.y = -GetScrollPos(SB_VERT);
I hope this helps!
INTP
|
|
|
|
|
Thanks John for the in-depth explanation...
...but the data in my view doesn't scroll in the way that CScrollView is implemented, and I need to disable this automatic scrolling.
Any idea how this can be done?
Thanks,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Below you will find a partial copy of the trace output from the code I am currently
working on. The "|" indicate the depth (scope) of th call, "->" indicate of function call, "<-" indicates a return from the function call, and "=" at the right indicate the value returned by the call or the result of a library function call.
Note: If you have a copy of Jeffrey Richters' Book "Programming Applications of Microsoft
Winodows'" then you might have some understanding of my problem here.
According to the book this should not be causing an EXCEPTION_ACCESS_VIOLATION.
But I would like to note that if I ignore the violation then the next allocation made with new (or malloc()) causes the EXCEPTION_ACCESS_VIOLATION "Attempt to WRITE data at address 00555555" instead of "Attempt to WRITE data at address 00414141". Therefore, I tend to beleive the address may be bogus (Windows internal thing). If I allocate using GlobalAllocate() or LocalAllocate() the the assess violation occurs at the next allocation made with new.
I would also like to point out that this only occurs on the second time the high level funtion (not shown) is called.
Questions:
Has any body seen this behavior before?
Has any body any idea what could be causing this to happen.
| |->CExBitmap::CExBitmap()
| |<- CExBitmap::CExBitmap()
| | CreateCompatibleBitmap(dcDest, 220, 240) = TRUE
| |-> CDibData::CDibData()
| |<- CDibData::CDibData()
| |-> CreateDIB(pBitmap, FALSE)
| | |-> CreateBitmapInfo(pBitmap, 0012EFFC)
| | |<- CreateBitmapInfo() = 020F0198
| | | new BYTE[53864] : EXCEPTION_ACCESS_VIOLATION
| | | ExceptionCode = 0xC0000005
| | | ExceptionFlags = 0x00000000
| | | ExceptionAddress = 0x77F596CF
| | | NumberParameters = 0x00000002
| | | ExceptionInformation[0] = 0x00000001
| | | ExceptionInformation[1] = 0x00414141
| | | Attempt to WRITE data at address 00414141
| | | BaseAddress = 00414000
| | | AllocationBase = 00400000
| | | AllocationProtect = PAGE_EXECUTE_WRITECOPY
First-chance exception in SPaint.exe (NTDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in SPaint.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
| | | "There is nothing you can do to this region to raise an
| | | access violation. Attempt to write to memory in this
| | | page cause the system to give the process its own
| | | private copy of the page (backed by the paging file)."
| | | RegionSize = 188416
| | | State = MEM_COMMIT
| | | Protect = 32
| | | Type = MEM_IMAGE
INTP
|
|
|
|
|
hi.... could anyone tell me links/place to find tutorial that explain how to build opengl application in SDI/MDI (single/multiple document interface)
thanks...
|
|
|
|
|
try MSDN though i don't think they'll have alot of info on it.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
LOL hell ya go to http://www.msdn.microsoft.com/library/default.asp[^] and then you see the tree control?, go to graphics and multimedia and expand that then find Open GL. OMG I didn't know microsoft had this much ... stuff ... about Open GL!!!!! ;)
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Yes I want to go back but there is a reason. I need a website dedicated to old c++
not like alot of other things can anyone suggest any websites?
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
What do you need to know ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I need to know how to use c++ file i/o very well especially the file input to the program.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Then read my articles on iostreams and ask any questions you like.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|