View Single Post
  #7 (permalink)  
Old 07-07-2007, 06:14 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
Quote:
Originally Posted by HelloWorld View Post
is printf new in C++ as it is new in Java? Is there println in C++ as it is in Java I've read about cout << "Hello" << something like that, but I'm not sure if you can do that as if you do in println() command

that's because I think using println() is much easier than having to remember all % for printf statement, well it's probably better if you can remember all of them, but I think I'd just print what rpgfan said out and put it in front of your computer or... yeah, go to C++ reference site
printf is not new in C++ because C++ evolved from C. You can think of C++ as an extension of C sort of. In C, you include <stdio.h> to use printf. In C++, you include <cstdio>, which refers to the fact that stdio is a C header. Others in C++ include <cstdlib>, <ctime>, etc. (remove the leading 'c' and add ".h" at the end to convert the header notation to C)

As for Java's System.out.println (or System.Console.WriteLine in C#), there is no such thing in C++. The closest thing to it is the std::endl member:
std::cout << "Hello world!" << std::endl; // C++
// System.out.println("Hello world!"); // Java
// System.Console.WriteLine("Hello world!"); // C#

Of course, if you included "using namespace std;" at the beginning of the C++ program, then you don't need to type "std::" to show that the member belongs to the std namespace.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote