|
What's wrong with:
int menu( void )
{
int choice;
do
{
printf("\nEnter choice (1-4): ");
choice = _getche();
} while (choice < '1' || choice > '5');
return choice;
}
void main( void )
{
int choice;
while ((choice = menu()) != '5')
{
switch (choice)
{
case '1':
...
}
}
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Well its like it does not want to accept any input whether text nor digits
-oam-
there might be something missing because it does read input and i can't figure it out
|
|
|
|
|
Well i used the other method which i found it simpler even though longer that the one you suggested.
printf("\nEnter choice (1-4): ");<br />
valid = 0;<br />
while( valid == 0)<br />
{<br />
fgets(iobuf,sizeof(iobuf),stdin); <br />
len = strlen(iobuf)-1;<br />
iobuf[len] = 0;<br />
valid = 1;
for(i = 0; i < len; i++)
{<br />
if( !isdigit(iobuf[i]))<br />
{<br />
printf("\nPlese enter numeric digits only (1-8):");<br />
valid = 0; <br />
}<br />
}<br />
break;<br />
}<br />
choice = atoi(iobuf);<br />
<br />
scanf("%d", &choice);
return choice; <br />
}
Thanks anyway.
-oam-
|
|
|
|
|
This much code to get a simple number is a maintenance nightmare waiting to happen.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The code snippet I provided does indeed work. Are you sure you typed it in correctly?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
in my keyboard hook dll i have used a global variable in all functions of that dll. I get value of that variable when control is in dll calling application. but if control is in another application (notepad or word) it won't get the global variable's value.
|
|
|
|
|
Global varible does NOT mean global concerning multiple processes!!
That global just means then you can access it from every function of ONE process.
If you want to access the variable from multiple processes then you have to share it!
To make it more clear:
The DLL file format (called PE file format) consists of sections. These section can have different settings. You code normally uses a section called .text, and the global variables use .data.
When a DLL is attached to a process, the sections are checked whether they contain data or code, and weather they sould be shared accross the whole system.
If sharing is not used, then the .text section is loaded and initialized by the code from the DLL file, but the .data section gets NEW memory, which is then initialized by the main function of the DLL file.
That would mean, that every process with the DLL attached to it, there is a completly new .data section which has different physical addresses in your RAM.
So when you want to share such a global variable over many processes, then you need to add a new shareable section or modify the whole .data section to make it shareable (which is not very reasonable).
To create a new section use this code:
#pragma data_seg( ".share" )
HANDLE hFileHandle = 0;
#pragma data_seg()
#pragma comment( linker, "/SECTION:.share,RWS" )
Don't try it, just do it!
|
|
|
|
|
Hi, all
I have an MFC application that uses CHtmlView to display the contents of an xml file (xml source).
I use the CHtmlView()->Navigate2(sFile,NULL,NULL); function, and it displays the xml source in internet explorer style (coloring, xml node explansion, etc), I use it also to display plain text files content, however, in some computers when using the Navigate2 method it launches a separate Notepad window and displays an IE error message: "Action canceled
Internet Explorer was unable to link to the Web page you requested. The page might be temporarily unavailable". In others it displays the file source. Any hint on how to force it programaticaly to display the text file contents?
thanks,
Oscar
|
|
|
|
|
Hello, All!
I have a some problem, may be smbd can help me.
So, I have a RichEdit window and have to use it like console window (so, use any functies for stdout and strdinm, for example, FillConsoleOutputCharacter, SetConsoleCursorPosition and so on). May be smbd know how to do it...
PS: I just trying to rewrite a console application of telnet-client with supporting vt100 and esc-sequenses and have a problem with a positional output.
Thanx for all answeres!
|
|
|
|
|
if you have a problem with '\n' , replace them with '\r\n'
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
No, not this problem. Problem with rewriting information which sending from telnet-server. For example, if we send the "top" command to telnet-server information in RichEdit have to redraw not all but in special position.
|
|
|
|
|
I'm not sure I understand, but does Invalidate() function work for you ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Big thanx! Try to use it!
|
|
|
|
|
Now have a new problem - i'm using a VC 6 but this project on a C#, and i can't include this dll to my project
|
|
|
|
|
*Differences between VxDs and DLLs (Win9x)
*when to write a VxD or when to write a DLL (Win9x)
*how to write VxDs in C or C++.
Tell Me Please
|
|
|
|
|
A VxD is a Virtual Driver
A DLL is a Dynamic Link Library
A DLL is a library of functions, classes, etc that can be use by any program which wants to stay a bit modular.
A VxD don't have any relationship with this...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
VxDs only for kernel-mode drivers.
That means, if you don't need any functions only accessable from kernel-mode (e.g. direct device access), then you don't need a VxD.
Don't try it, just do it!
|
|
|
|
|
Hi all:
What "0L" stands for, "L" is the data type "Long" right?
But in the statement above, is "L" a operator or something else?
Thanks
|
|
|
|
|
|
The "L " is simply part of the C/C++ language syntax for identifying "long " integer constants. In Visual C++, this isn't used as much as it was at one time. Currently, the int and long variable types are both 32-bit signed integers.
In 16-bit environments, int values were typically 16 bits, and you have to use long to get a 32-bit value. This was the case in Windows 3.1 and MS-DOS programming.
Software Zen: delete this;
|
|
|
|
|
i don't agree entierly
char is 8 bits long
short is 16 bits long
long is 32 bits long
BUT int depends on the system. 16 bits for example on Windows 3.1, 32 n WinNT, Win2K and current WinXP, but in few weeks, XP 64 will be available. int will so be 64 bits long !!!!!!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
On Win32, long is 32 bits, not 64. Even on Win64, long is still a 32 bit integer.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
yes sorry, i know that, i just made a mistake while typing the post...
i edited it now
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You'll notice I qualified my statement by saying "Currently, the int and long variable types are both 32-bit signed integers". This statement is true for C++ compilers used in the Windows environment (any other environment doesn't apply; this is a Windows programming site, after all). I didn't think it necessary to be pedantic about it, given the elementary nature of the original question.
Software Zen: delete this;
|
|
|
|