I'm trying to simulate the history of a shell like script. The first step (at least from what I think) is to make it recognise the up or down arrows. Let me show you the code first:  string readSequence() {     int c;     string currLine;     do {        if (getchar() == '\033') { // if the first value is esc             getchar(); // skip the [             c = getchar(); // get the real value                 if(c == 'A') // the real value                     cout &lt;&lt; "up";                 if(c == 'B')                     cout &lt;&lt; "down";         }     } while(c != EOF || c != '\n'); }   Whenever I run this in the command line, if I press up down up down for instance, it will print ^[[A^[[B^[[A^[[B, and after I press enter it will print updownupdown. I'm trying to make it print up or down as soon as the user presses up or down, and also make it not to print those ^[[A or ^[[B things.  Also, if you got any suggestions on how to do this in another way, please do share. Thanks in advance!
I can never remember how I do this because it comes up so infrequently for me. But in C or C++, what is the best way to read a character from standard input without waiting for a newline (press enter).  Also ideally it wouldn't echo the input character to the screen. I just want to capture keystrokes with out effecting the console screen.
I've got this situation:  ./ ./myscript.sh ./arguments.txt ./test.sh   Inside myscript.sh, I have to run the file test.sh, passing to it the arguments contained inside arguments.txt.  myscript.sh is:  arguments=$(cat arguments.txt) source test.sh $arguments   This works well if if arguments.txt contains at most one argument:  firstargument    The substitution is:  ++ source test.sh 'firstargument'   But the problem is with two or more arguments. It does this:  ++ source test.sh 'firstargument secondargument'   Also, I don't know in advance the number of arguments inside arguments.txt. There can be zero or more. Does it just vanish into space leaving nothing behind or does it expel some material?    Also, talking more about black holes, as far as I understand the term "temperature", it is defined by the amount of kinetic energy of the particles of a body and from what I have read, there are no particles inside a black hole, I know that you can find the temperature of a black hole by analyzing its Hawking radiation but I cant really understand how the term "temperature" can be applied to a black hole. Does it mean that whatever is that it is inside a black hole has kinetic energy? Have physicist already experienced the death of any regular black hole (by regular I mean space-sized black holes not micro ones created in labs)? Also, where is the Hawking radiation form? Because if it is released by the black hole I bet it must have formed outside the event horizon, but how exactly? Redirect Restricted Page to 404 Is there a way to show a 404 page if the current logged in user does not have the right clearance to view the page? I am looking for a PHP method, something like  if( !current_user_can('administrator') ) { show_404(); exit(); }   I have thought about using a redirect, but I would like to keep the url the same. In counting degrees of freedom of a linear molecule, why is rotation about the axis not counted? I have a 8 GB pendrive. I used to write raw data into the pendrive (without creating filesystem) using the dd command.    Today, when I inserted the pen drive, the I am unable to write anything on to it.  When I open gparted it is showing the total space on the pen drive as 500 MB. I am unable to create a new partition table or a partition on the pen drive now.   Here is the fdisk -l output.   Disk /dev/sdb: 0 MB, 512000 bytes 255 heads, 63 sectors/track, 0 cylinders, total 1000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00095df6   What's wrong with the pen drive? How can I recover the lost space?   Device Boot      Start         End      Blocks   Id  System   When I open gnome-disks, it shows the total space as 8 GB but when I try to create a new partition using it, it shows the following error:  Error creating partition on /dev/sdb: Command-line parted --align optimal --script "/dev/sdb" "mkpart primary ext2 1MiB 7969177599b"' exited with non-zero exit status 1: Error: The location 7969177599b is outside of the device /dev/sdb.  (udisks-error-quark, 0) Are there surface-mount pin header footprints for KiCAD? Why don’t I have the Get Windows 10 icon? I want to get Windows 10, but I do not see this icon in the notification area (tray):    How do I get the icon to get Windows 10? How do I with ufw deny all outgoing ports excepting the ones I need? Identify GoogleTv from Android app How do I update Custom Label's value using apex? Which one would be a better option metadata api or tooling api? Please provide example Please help me prove this. I'm not sure how to apply the parallelogram law to the norm. Are Jedi bound by a code of honor or morals? In The Phantom Menace alone, Qui-Gon (and in part Obi-Wan) are quick to use Jedi mind tricks and not only gamble but also cheat at it. They seem happy with this fact.  Do Jedi have morals and ethics, or a code of honor? If no spell can reawaken the dead, how did the resurrection stone work? Dumbledore himself said that no spell can reawaken the dead. Isn't that the main objective of the resurrection stone? If one can't reawaken the dead then what is the use of the stone? Surely then one of the Hallows is flawed? "NG NS" on ticket after airport security I went through security at the Sacramento Airport with a friend. He got something written on his boarding pass "NG NS". I didn't have that. We both went through the same metal detector, neither beeped nor had random checks. Flying to Edmonton through Seattle connection. Early for flight.  I have tried searching for "what is tsa ng ns" on Google but nothing useful came up. Any ideas? Exclude a view from master layout? Redefining \listoffigures and \listoftables as tables Let $f$ be a real valued, continuous and differentiable function on the real numbers with $f'$ uniformly continuous. Show that $g_n(x)$ with $$g_n(x)=nf(x+1/n)-nf(x)$$ is uniformly convergent to the derivative of $f$.   I cannot figure out how to solve this problem. If anyone could help me for this problem I would be very grateful. Change of flavour, Weak interaction I couldn't find a straight and clear answer to this question on the internet: Why is the weak interaction (charged), the only interaction which can change the flavours of the quarks? Sentences with "no one" What are the mechanics by which Time Dilation and Length Contraction occur? What are the mechanics of time dilation and length contraction? Going beyond the mathematical equations involving light and the "speed limit of the universe", what is observed is merely a phenomenon and not a true explanation of why time dilates or length contracts.  It has been proven to work out, but do we know why?  Is it something that happens at a subatomic level?