Hello i want to use _cscanf without the input character being echoed.For example when i press ENTER to finish the reading it echoes '\r' or when i was press backspace it echoes '\b'.But i dont want to input them.From microsoft site ( http://msdn.microsoft.com/en-us/library/tsbaaw16.aspx ) : "While _cscanf normally echoes the input character, it does not do so if the last call was to _ungetch."
How can i use that ? I tried :
1 2 3 4 5 6 7 8 9 10
#include <conio.h>
int main()
{
int a,b,c;
_ungetch('\r');
_cscanf("%d%d%d",&a,&b,&c);
_cprintf("<--The numbers should be there");
return 0;
}
, but it does not work. Can someone show me how to do this?
OK i get it you cant.If _cscanf reads data from _ungetch it does not echo it,else it does.Pretty bad i wanted a function that reads data and leaves the cursor at the same position after finishing reading.Not inserting a newline or something like that...(like cin and scanf does...)
I dont understand why its called depreciated.Since its a microsoft product its suportted by them in every of their ide even in visual studio 2013.And believe me conio.h is used in pretty almost every console game ive seen.And what its so bad about it?Ive watched the source code of its functions and its seems it pretty much uses win api ,to get direct console input,output.Its windows.h bad and depreciated too?
And yeah about the non standard thing you are right unfortuanatly.On some compilers conio's functions dont behave like others compilers functions...
For example on borland one if i write:
#include <conio.h>
int main()
{
_cprintf("Hello World\n");
_getch();
_cprintf("See where the cursor is ?");
return 0;
}
the '\n' its not going to jump at the end of the line but its just going to move the cursor a line down.
To get the same effect you wanted you had to write "\n\r".
But on visual studio for example if i write the same thing its just going to jump at the end of the line auttomaticly, and microsoft said
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// crt_cprintf.c
// compile with: /c
// This program displays some variables to the console.
#include <conio.h>
int main( void )
{
int i = -16,
h = 29;
unsigned u = 62511;
char c = 'A';
char s[] = "Test";
// Note that console output does not translate \n as
// standard output does. Use \r\n instead.
//
_cprintf( "%d %.4x %u %c %s\r\n", i, h, u, c, s );
}
, that it acts like borland but again you dont need that '\r' because it just jumps to the beggining of the line anyway :(( ...
windows.h is *not* standard either. but every windows programmer use it (even when using an external library/framework). How about that ? Or how about WinMain ? Is not a standard entry point either.
Yeah i know i wanted to tell that to him too.And conio.h is not deprecated! It may been out for some time but its functions are still very useful.Too bad though the functions form borland conio (clrscr,textcolor,textbackground....) are only availble in borland.Now if we wanted to do that we will have to write our own functions in WIN API, which is pretty hard for newbies to c++ to do that.If we had them anyone could easily play with the console.
In accountancy, depreciation refers to two aspects of the same concept:
the decrease in value of assets (fair value depreciation), and
the allocation of the cost of assets to periods in which the assets are used (depreciation with the matching principle).
Deprecated:
Deprecation is a status applied to a computer software feature, characteristic, or practice indicating it should be avoided, typically because it is being superseded.
(both from Wikipedia).
conio.h is deprecated because 'it should be avoided', mainly due to the inconsistencies between different compilers (and versions of the header). Better options are to use libraries like pdcurses, or even just to use the Win32 API. Contrary to what most people seem to think, the API isn't actually all that tough to learn or use, the only difficulty is the sheer number of options that are provided, and (for some) the fact that it uses a C API, rather than an object-oriented C++ one. However, for the former issue, MSDN is your best friend, and for the latter, either there are wrappers that can be used (such as MFC) or you could just accept the fact and live with it.