|
Hello,
When I created a small test file:
<code>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int number;
cout << "Enter a number (1 or 2): ";
cin >> number;
if (number != 1 || number != 2)
{
cout << "You didn't enter a 1 or 2" << endl;
}
else
{
cout << number << endl;
}
return 0;
}</code>
The result always "You didn't enter a 1 or 2" no matter what number was entered. I tried changing the code to:
<code>
if ((number != 1) || (number != 2))
</code>
with the same results. Any clues? Thanks in advance.
|
|
|
|
|
|
Shane Ragone wrote: (number != 1 || number != 2)
Try writing a truth table for this and see what the result is . You'll find that the result is always true. What you actually want is if (number != 1 && number != 2)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi guys,
I am using isinf() function in my program. But in VC++ it is giving me the error "isinf undefined identifier". Does anybody know how to make isinf() function work in VC++?
Thank you very much.
jay111
|
|
|
|
|
_fpclass
bool isinf(double d)
{
int fpc = _fpclass(d);
return fpc == _FPCLASS_NINF || fpc == _FPCLASS_PINF;
}
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
hi peterchen,
thanx for your reply. I didnt quite get what you r saying in your reply...I can compile my program in unix shell with gcc compiler without any error. But i want to port my project to VC++. But in VC++ it is giving i m getting the error.
thanx,
jayashri
jay111
|
|
|
|
|
What peterchen is (probably) telling you is that isinf() is not part of the Win32 API, hence the need to make your own.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
oh ok...thanks. so there is not easy way to check for infinity in VC++...
jay111
|
|
|
|
|
jayashri2006 wrote: so there is not easy way to check for infinity in VC++...
Not that I know of, unless you are using the .NET framework.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
oh, actually I am using .net framework...do u know the alternative way?
jay111
|
|
|
|
|
Then check out the Double.IsInfinity() method.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
Hi All,
In VS 6 I copy data from a custom control on a dialog using my own clipboard management (see code below) and would like to paste it into a CEdit on the same dialog. I believe I am getting it to the clipboard correctly, in CF_TEXT format because I can paste the text into WordPad or Notepad just fine. I am unable, however, to paste my clipboard contents to the CEdit either with the CEdit context menu or Ctrl+V. Making this all the more confusing is that if I copy text from Wordpad, which presumably is in CF_TEXT format, I am able to paste into the standard CEdit just fine.
Any ideas would be greatly appreaciated!
Thanks,
Doug
CString cellText = "This is a test";<br />
<br />
<br />
OpenClipboard();<br />
EmptyClipboard();<br />
<br />
<br />
int dataStringLen = cellText.GetLength();<br />
HANDLE dataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,dataStringLen + 1);<br />
char *memPtr = (char *)GlobalLock(dataHandle);<br />
<br />
<br />
memcpy(memPtr,(char *)(LPCTSTR)cellText,dataStringLen + 1);<br />
memPtr[dataStringLen] = '\0';<br />
<br />
<br />
GlobalUnlock(dataHandle);<br />
SetClipboardData(CF_TEXT,dataHandle);<br />
GlobalFree(dataHandle);<br />
<br />
CloseClipboard();
Doug Knudson
|
|
|
|
|
<br />
if(OpenClipboard()){<br />
CString cellText = "This is a test";<br />
HGLOBAL clipbuffer; <br />
EmptyClipboard(); <br />
clipbuffer = GlobalAlloc(GMEM_DDESHARE, cellText.GetLength()+1); <br />
<br />
char * buffer; <br />
buffer = (char*)GlobalLock(clipbuffer); <br />
strcpy(buffer, LPCSTR(cellText)); <br />
GlobalUnlock(clipbuffer); <br />
SetClipboardData(CF_TEXT,clipbuffer); <br />
CloseClipboard();<br />
}<br />
hi
|
|
|
|
|
Thank you very much! Works like a charm!
Doug
Doug Knudson
|
|
|
|
|
Hello i How can i read a string from a listbox ( MFC)
Thanx a lot !
|
|
|
|
|
By using the CListBox::GetText() method.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Mahhouraaaaaa wrote: How can i read a string from a listbox ( MFC)
CString strData;
m_list.GetText(m_list.GetCurSel(),strData); m_list is the Control variable of the CListBox Control.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I try to share .pch (precompiled header files) across my library (more than 50) but i failed.
Using VC+ 6.0 is possible to share the .pch file reducing compilation time but when i try this in VC+2005 i ave found a lot of problems...
Can anyone help me?
Tanks and sorry for the poor english...
|
|
|
|
|
topus wrote: ...but i failed.
What failed?
topus wrote: Using VC+ 6.0 is possible to share the .pch file reducing compilation time...
I suppose you could in theory, assuming the files comprising each project were the same, but are you sure you want to? Why not just let the .pch file get built once for each project and be done with it? Your apt to spend more time trying to 'share' the file than you would just building it for each project.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Lock at this:
"Rebuild using shared precompiled headers doesn't work"
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=105308&SiteId=1
|
|
|
|
|
Hi everybody:
i have a child frame with four splitters and five views, when i resize the child frame (decreasing for example) only the size of the first view decreases until it becomes zero, so the second view`s size starts to decrease, and so one
i want to make all the views shrinks equally when resizing the child frame
any help is appreciated
thanks alot
|
|
|
|
|
WM_SIZE
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
i know it must go in the onsize handler in the child
but i want to know how to do it?
|
|
|
|
|
Tarek Jabri wrote: i want to make all the views shrinks equally
Tarek Jabri wrote: but i want to know how to do it?
I don't understand what the problem is?
As the parent window size changes you have to calculate what "equal" is and then adjust the components (views, splitters, whatever) that are required, right?
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|