I am required to call an input method and a calculations method from main. Input will prompt the user to input 3 variables. Without using arrays, loops, or globalized variables, how can I return the 3 variables back to main to be passed as parameters to the calculations method?
Is there a preferred way to return multiple values from a C++ function?  For example, imagine a function that divides two integers and returns both the quotient and the remainder.  One way I commonly see is to use reference parameters:  void divide(int dividend, int divisor, int&amp; quotient, int&amp; remainder);   A variation is to return one value and pass the other through a reference parameter:  int divide(int dividend, int divisor, int&amp; remainder);   Another way would be to declare a struct to contain all of the results and return that:  struct divide_result {     int quotient;     int remainder; };  divide_result divide(int dividend, int divisor);   Is one of these ways generally preferred, or are there other suggestions?  Edit: In the real-world code, there may be more than two results.  They may also be of different types.
New global search doesn't like tags I have a SQL script that creates a package with a comment containing an ampersand (&amp;). When I run the script from SQL Plus, I am prompted to enter a substitute value for the string starting with &amp;. How do I disable this feature so that SQL Plus ignores the ampersand? How may I reference the script tag that loaded the currently-executing script? Windows 98 on a modern computer? Tree level QFT and classical fields/particles What do you call a sick person who is lying in bed? Are nested transactions allowed in MySQL? Redirecting cout to a console in windows I have an application which is a relatively old. Through some minor changes, it builds nearly perfectly with Visual C++ 2008. One thing that I've noticed is that my "debug console" isn't quite working right. Basically in the past, I've use AllocConsole() to create a console for my debug output to go to. Then I would use freopen to redirect stdout to it. This worked perfectly with both C and C++ style IO.  Now, it seems that it will only work with C style IO. What is the proper way to redirect things like cout to a console allocated with AllocConsole()?  Here's the code which used to work:  if(AllocConsole()) {     freopen("CONOUT$", "wt", stdout);     SetConsoleTitle("Debug Console");     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); }   EDIT: one thing which occurred to me is that I could make a custom streambuf whose overflow method writes using C style IO and replace std::cout's default stream buffer with it. But that seems like a cop-out. Is there a proper way to do this in 2008? Or is this perhaps something that MS overlooked?  EDIT2: OK, so I've made an implementaiton of the idea I spelled out above. Basically it looks like this:  class outbuf : public std::streambuf { public:     outbuf() {         setp(0, 0);     }      virtual int_type overflow(int_type c = traits_type::eof()) {         return fputc(c, stdout) == EOF ? traits_type::eof() : c;     } };  int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {     // create the console     if(AllocConsole()) {         freopen("CONOUT$", "w", stdout);         SetConsoleTitle("Debug Console");         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);       }      // set std::cout to use my custom streambuf     outbuf ob;     std::streambuf *sb = std::cout.rdbuf(&amp;ob);      // do some work here      // make sure to restore the original so we don't get a crash on close!     std::cout.rdbuf(sb);     return 0; }   Anyone have a better/cleaner solution than just forcing std::cout to be a glorified fputc? How to get distance when acceleration is not constant? I have a background in calculus but don't really know anything about physics.  Forgive me if this is a really basic question.  The equation for distance of an accelerating object with constant acceleration is:  $$d=ut        +\frac{1}{2}at^2$$  which can also be expressed  $$d=\frac{\mathrm{d}x}{\mathrm{d}t}t+\frac{\mathrm{d^2}x}{\mathrm{d}t^2}\frac{t^2}{2}$$  (where x(t) is the position of the object at time t)  That's fine for a canonball or something like that, but what about a car accelerating from 0 to cruising speed?  The acceleration is obviously not constant, but what about the change in acceleration?  Is it constant?  I suspect not.  And then what about the change in the change of acceleration, etc. etc.?  In other words, how does one know how many additional terms to add in the series?  $$d=\frac{\mathrm{d}x}{\mathrm{d}t}t+\frac{\mathrm{d^2}x}{\mathrm{d}t^2}\frac{t^2}{2}+\frac{\mathrm{d^3}x}{\mathrm{d}t^3}\frac{t^3}{3}+\frac{\mathrm{d^4}x}{\mathrm{d}t^4}\frac{t^4}{4}\cdot etc. \cdot ?$$ I have quite a bad habit of copy-and-pasting my packages from one LaTeX document to another. Is there any way we can detect unused packages (i.e. \usepackage commands) so that they can be removed from the LaTeX document? This is my first question in /photography. I'm a very amateur photographer, doing things wrong and by eye with lots of trial-and-error all the time.  I currently own a reflex Nikon D70 my uncle gave us after he bought a better one. It has some nice settings, and he bought a a Nikkor 28-80mm F/3.5-5.6 zoom lens for it. It behaves nicely, but it's getting old (it has those old cartridges before SD cards existed) and every new charge takes longer than the last.  I'm planning to upgrade to a better camera, and there are some neat offers on a nearby superstore (MediaMarkt), this one catching my eye:  Sony DSC-H400 63x, Sensor Super HAD 1/2/3 CCD 20.1MP -> for less than 300€ taxes included  I don't have any type of extra information aside from that, all I can get from the official site is clinical data from other cameras that I suspect it's not 100% accurate, and there's no photography expert on the store to ask.  The common things I use my D70 for are: taking pictures of scenery (castles, towns, forests, waves hitting rocks, etc...), nearby (&lt;5m) persons and objects, and well, things where I want to save a memory in digital format, not for professional purposes at all.  Being that my objective is to have a decent, good-zooming (superzoom looks awesome), amateur (but with manual settings) camera, is this Sony a good replacement? Will I miss any features? Is there any better, similarly-priced alternative you know of?  Basically, I want to know whether I will get better quality photos than I currently do, given the examples, with any averagely-priced bridge camera similar to that Sony, and if it's worth it.  examples of current camera results  Full zoom-out of town at night, bad quality I know; notice the pink blur at the left.    Maximum zoom on that pink blur from almost the same spot:    Daylight, cloudy, modified with Adobe Lightroom, scenery:    Same day, same beach, different settings:    Same day, same beach, rocks: Why isn't sizeof for a struct equal to the sum of sizeof of each member? Open a direct file on the hard drive from Firefox (file:///) I have a small PHP system I created for myself. This system contains a few .doc and .docx file documents. I want to be able to open them directly from the browser without downloading them.  I created a link: &lt;a href="file:///c:/mysite/myfile.docx"&gt;myfile&lt;/a&gt;. But Firefox does not open the link. href="http://localhost/myfile.docx" works fine - it offers me to download the file.  Any ideas on how I can do it? Do I need to change something in the Firefox options or security settings? Inferring father/son relationships from Senior (Sr.) / Junior (Jr.) naming? As in my other questions, I am investigating the spread of the Blackstone family name in early America. I came across the following tidbits and I would like to know if my interpretation is (likely to be) correct.  In the "All Kent County, Delaware Probate Records, 1680-1800" collection on ancestry.com, we have the following items.   In 1792, there was a will executed by Eben Blackiston, Sr. In 1794, there was a will executed by Ebenezer Blackiston, Jr. (and Abraham Redgrave).   My question is simple.  Is this enough evidence to reasonably conclude that there was a father/son combo of Ebenezer Blackistons living in Kent County, Delaware during the 1790s?  This would be an interesting result for me as my current research only has two people by this name in the state at the time, and none of them were part of a Jr./Sr. combination.  If this is not enough evidence, what are some other possibilities I need to consider? Retrieve Force.com registered domain What is the difference between an int and an Integer in Java and C#? I was reading  when I came across  saying something about a particular type of programmer knowing the difference between an int and an Integer in Java/C# (Object-Oriented Programming Languages).  So, what is the difference? Is there any way to prevent mc from taking 10-30 seconds to open? Taking ownership of comments on migrated questions When a question is migrated to a SE site that I'm not registered to, I can't claim ownership of my comments. An example question:   I registered only after the question was migrated and can't delete my comments. I always like to perform some garbage collection of noise comments made by me. (like on the example question)  Would it be possible to claim ownership of comments in this scenario? Is this a bug? What is the difference between the three sentences below?   I have been married with her for three years. I was married with her for three years. I married her for three years. Is there a way to find self-answers with the advanced search? Preferably, not using the  and including results of all time and not just the recent ones with the new share your knowledge, Q&amp;A-style