Talk:C++ Programming/Q&A

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Welcome to the C++ Programming questions and answers page.
Feel free to post any questions you have while learning to program in C++.
If you have questions about this book, post them on the C++ Programming content discussion page.
If you know the answer to a question, or you can improve any, go ahead and do it.
After a response is given and the information is missing in the book, please add it and delete the post.
(give at least 7 days after the reply, no archive is needed to be maintained of this page).


Question Mark.jpg Ask a question! See that you are logged into Wikibooks



Contents

[edit] how to move a text up and down using keys?

how to move a text up and down using keys?

You have to intercept the pressing of the keys, see the book example on how to get input from the keyboard and adapt it to detect those key presses, if you don't know the code for a particular key, print it to the screen after you have read it. if you think the example on how to get the keyboard data is missing something please ask again, please do sign you posts txs --Panic 14:41, 7 January 2007 (UTC)

[edit] Three variable equations

How can you solve three variable equations in C++?

I will not provide a direct answer to the question but you can start by writing the steps in pseudocode and then implement the resulting algorithm in C++. --Panic 19:12, 9 August 2007 (UTC)

[edit] how to build stand alone programs in C++

hi, i need one to help/teach on how to build stand alone (executable) program from C++ code scripts i.e. the .h and .cpp code files. thanx

In place of calling code script call it source code, the requested information is present in C++ Programming/Code and C++ Programming/Compiler with a practical example here C++ Programming/Examples/Hello world, I think that will help you. --Panic 18:55, 9 August 2007 (UTC)

[edit] problem

pls how can i solve this solution

1. write a program that will ask the user to

 enter 10 integer numbers from the keyboard
 (using array), print out the first and the 
 second largest numbers only the screen.
 
thanks in anticipating a reply.

See C++ Programming/Exercises/Iterations that may help you. --Panic (talk) 17:34, 30 October 2008 (UTC)


what is stream in c++?

See C++ Programming/Code/IO/Streams --Panic (talk) 18:00, 25 January 2009 (UTC)

accept two no from user and print the series in between while, do while, for loop then answer? —The preceding unsigned comment was added by 60.243.114.134 (talkcontribs) .

See C++ Programming/Code/Standard C Library/IO and C++ Programming/Code/Statements/Flow Control. --Sigma 7 (talk) 14:32, 3 March 2009 (UTC)

[edit] string::find return type

Which one is right?

  • string::find() returns an int ? -- old version of C++ Programming/Code/IO/Streams/string; but the compiler I'm using today tells me "warning: comparison between signed and unsigned integer expressions".
  • string::find() returns a size_type ? -- SGI reference; but the compiler I'm using today keeps telling me "error: 'size_type' was not declared in this scope".
  • string::find() returns a size_t ? -- another C++ reference; this seems to compile -- on this ancient compiler I'm using today. But is it portable?

--DavidCary (talk) 02:32, 16 March 2009 (UTC)

What compiler are you using? size_type is the correct one, by what is on the 2003 standard.
Use string::size_type return = yourstring.find( <what you need to find> ); and the "error: 'size_type' was not declared in this scope" should be solved. --Panic (talk) 19:06, 16 March 2009 (UTC)
Ah, that makes sense. Now my compiler accepts it. So actually
  • string::find() returns a string::size_type
right? --DavidCary (talk) 04:04, 18 March 2009 (UTC)
Well the correct terminology is that the type is size_type, the string:: bit is the namespace were the compiler can find a definition for it, in general a type can be the same or different across several namespaces sharing the same keyword, in this case it also exists in other namespaces (ie vector::size_type) and from your previous searches it seems that some time back it was a int.
For what is on the standard (2003) the size_type is implementation dependent and size_t will (with a high degree of certainty) be equal to size_type (but the standard doesn't commit to it and I couldn't find a clear reason why...) --Panic (talk) 04:44, 18 March 2009 (UTC)
Thank you. OK, I've updated C++ Programming/Code/IO/Streams/string based on the new understanding you've given me. As always, feel free to improve that page, even if it means reverting my mis-guided edits. --DavidCary (talk) 13:58, 24 March 2009 (UTC)

[edit] mathematical operations

a c++ programe that can display mathematical operations.

No major problem, the only difficulty would be the output but that depends only on how much it needed to conform with the standard notation. You could output a TeX formula and render it elsewhere. --Panic (talk) 19:50, 18 May 2009 (UTC)