Question:
Data types and cout for C++?
anonymous
1970-01-01 00:00:00 UTC
Data types and cout for C++?
Four answers:
anonymous
2016-08-07 17:08:03 UTC
You don't say how you checked that you had been using the right indices on each arrays. I relatively have got to marvel about that considering the sizes of the arrays are exceptional and you don't exhibit how you might be enhancing the indices to your loop.
Unca Alby
2013-03-10 19:28:10 UTC
"printf" sends its output to the Standard Output, or "stdout". Most of the time that will be your screen on a command line application, or it may be redirected to the Standard Input (stdin) of some other program.



"cout" does the same thing, only it uses different buffers and different formatting rules. If you use "printf" and "cout" in the same program, you're asking for heartburn due to issues with different buffers. You'll expect your output to be intermingled, but instead, all of the buffer from one output command will be completed before starting the buffer from the other.



"cout" happens to be located in the "std" namespace (standard), and many times a programmer will start a file with the line:



using namespace std;



If that is NOT done, then you MUST use "std::cout" to specify explicitly what namespace the variable is located in.



You can also use "std::cout" when "using namespace std", but it's just redundant.
Shady
2013-03-10 19:24:20 UTC
when you put using namespace std;



it is the same as if you didn't put it and did std::cout



printf is C.



Since it is backwards compatible with C++ you can use it on a C++ compiler.
anonymous
2013-03-10 19:45:46 UTC
either printf or cout are fine for learning c/c++. When you start learning classes you will understand cout/cin more clearly. If you are going to continue on advanced programming you will likely will start learning c/c++ implementations in windows/ mac osx, games libraries, data base and the list goes on and you won't likely need to worry about command line programming as much.



I think you should be confident in both printf, sprintf, fprintf, fsprintf and all of the iostream libraries, you will need them. Some of the C functions are deprecated, but when you are learning they are fine. It is nice to be able to make quick and dirty programs to create a file or database that you can test out your code and you can even generate code if you are clever.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...