|
if u want the ascii value.....go ahead and declare enter1 as int type but get it with functionz like getch() or getche(),or some function other than cin
if u want to use cin ,then declare the enter1 as char type
hope that helpz.....
happy programmin.....
cheerz.....
|
|
|
|
|
This might be obvious, but in many cases you must hit return before input is accepted. That is if you type the number but don't hit the enter key input will not be returned, even though you typed it!
Beginners mistake, but you did say you were a beginner.
|
|
|
|
|
Hello all,
Would anyone tell me that how C++ prevent the static variable been created more than one? Eg, if I have a function that contains a static variable:
<br />
void f() {<br />
static classA a;<br />
a.print();<br />
}<br />
<br />
void main() {<br />
f();<br />
f();<br />
}<br />
How C++ prevents the static variable "a" inside the function to be constructed twice rather than once? If I inline the function f(), will it still works?
Thanks!!!
Nacho
|
|
|
|
|
Hi Nacho,
The static variable will get created only once (exactly, the first time f is invoked.) Are you observing something different?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hello,
Yes, I know that the static will created only once. But I want to know how C++ actualy implement this. And I want to know whether doing inline of f() will break the rule?
Thanks!
Nacho
|
|
|
|
|
But I want to know how C++ actualy implement this,
Well, how the compiler implements this feature is up to the compiler alone, I guess. You can assume the internally generated code will resemble in some way the following:
static bool __f_a_initialized=false;
static char __f_a_storage[sizeof(classA)];
void f()
{
if(!__f_a_initialized){
new (__f_a_storage) class A;
__f_a_initialized=true;
}
...
} Do not take this as the actual procedure implemented, it is just an approximation to what the compiler probably does. Does this answer your question?
And I want to know whether doing inline of f() will break the rule?
The rule does not break even if you declare your function inline .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
I m trying to place two dialogs (different types) one beneath the other , like a Horizontal Tile operation .
I need to compute the top Y coordinate for the bottom Dialog for which i need to take into account the height of the title bar of the First dialog
What is the API call to get this value ?
|
|
|
|
|
Look at GetSystemMetrics() and pass SM_CYCAPTION as its parameter.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I would like to start writing apps for my pocket pc running windows ce. I've just downloaded eMbedded Visual C++ 3.0 and I don't have a handle on it just yet. Can anyone direct me to a tutorial or a site for learning eMbedded?
Also, I've tried to enter some of my code into eMbedded (which compiles in .net) and it didn't work. Then I tried something simple. Why doesn't this code work in eMbedded:
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
return 0;
}
Thanks!
-Wp
|
|
|
|
|
I am using DirectX 9 with VS.Net 2002. When I call the Direct3DCreate9 macro I recieve an unresolved external error when the project links. I have included the platform sdk lib and include files as part of my .net setup and they are both at the top of the list. I am unsure of why I am recieving this error. Any help will be much appreciated.
|
|
|
|
|
Did you include d3d9.lib? If that doesn't help, include d3dx9.lib.
|
|
|
|
|
Thankyou for the help. Evidently I wasn't including the libraries in the right area in the project setup. Once I moved everything over to the additional dependencies area it all seemed to work out. I appreciate the help.
|
|
|
|
|
I have made my own compressed sound format, and i wish to play it as i decompress it back to pcm format.
The problem is this.
I wanna play them on the fly, as i decompress the music. Each music frame decompressed is 256 samples.
So a compressed music file, consists of alot of frames.
The few methods i have found to play music, requires a buffer to the entire length of the PCM data. Since that would require alot of ram, i see that as a problem, besides the fact, that it decompresses the entire file then plays the music.
|
|
|
|
|
I'm having a great deal of trouble with a Wizard97 design...
Briefly, Page 2 of the Wizard has 3 Radio Buttons.
Clicking "Next" takes you to page 3.
But how do I know what Radio Button was clicked from Page 2?
I would like to attach my code to this message, but I don't see how to do it. (?)
The code is very simple, but just doesn't seem to work and I can't see why it won't work!
|
|
|
|
|
if (((CButton*)GetDlgItem(IDC_MY_RADIO1))->GetCheck() == BS_CHECKED) {
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I wish it would work that way, but alas, it doesn't.
I keep getting an error message...
c:\Projects\Simple Wizard\Wizard.cpp(299): error C2039: 'GetChecked' : is not a member of 'CWnd'
|
|
|
|
|
The function you are looking for is GetCheck()
it returns one of BST_UNCHECKED , BST_CHECKED or BST_INDETERMINATE
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Now I get...
c:\Projects\Simple Wizard\WC_Wizard.cpp(295): error C2039: 'GetCheck' : is not a member of 'CWnd'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(1913) : see declaration of 'CWnd'
|
|
|
|
|
Why not break the code down into easier to read lines:
CButton* pButton = (CButton*)GetDlgItem(IDC_MY_RADIO1);
ASSERT(pButton != NULL);
if (pButton->GetCheck() == BST_CHECKED)
{
}
It always helps to breakdown the code.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
first, a made an error on the function, but someone else correct the mistake for me.
secondly, GetCheck() is a member of CButton, not CWnd...
if stdafx.h is included into your project, you shouldn't encounter such error (C2039).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You are missing an open bracket at the start of the if statement.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
You are missing an open bracket at the start of the if statement
correct... and corrected
but you understood what i would like to explain, isn't it ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I would like to set the listcontrol so that items (in the first column) *cannot* be selected. This can be done in a listbox, but is there any way to fix a listcontrol to behave this way ?
Thanks in advance,
Raymond Mercier
|
|
|
|
|
Hey,
Well a short question realy.
What does the ^ do in C++?
example:
int number = 0;
number ^= 1;
the output for number is 1. When in math would be 0.
Thanks.
humpa humpa
|
|
|
|
|
^ is the bitwise exclusive-or operator
SO :
0x1100
^ 0x1010
-----------
= 0x0110
that's why
number ^= 1;
means
number = number ^ 1;
means
number = 0 ^ 1; // == 1
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|