i've seen many programs using printf( ) for outputing(probable ported from C) but anyway, is there any difference between printf and cout?
also i've seen many functions(expecially in windows.h) using w_char*(wide char string) as arguments or return value(and it bugs me because it makes difficult to use with strings)
what's the difference, why they needed to make 2 types of strings, char string and w_char string?

Your basic console mode "Hello, World!" program comes in around 6 K using stdio.h and printf and anywhere between 250 K - 500 K using iostream and std::cout. For these reasons I never use iostream. I do console output with printf. Anyway, iostream isn't particularly useful in GUI.

Wide character strings are pretty much necessary, and if I were you I'd give up on using both the char data type and the wchar_t data type in favor of the TCHAR data type and the tchar.h macros (if you are using Windows, that is!). If you are going to interoperate between null terminated character buffers and the std::string or std::wstring classes you are going to have to get used to declaring instances of both and moving strings between them.

>> why they needed to make 2 types of strings, char string and w_char string?

Because there are languages other than English. The alphabet in some of those languages, such as Chinese, can not be represented by one-byte char variable.

There are two versions of all, or most, win32 api functions, one for standard char* and the other for wchar_t*. Microsoft VC++ compilers since version 2005 default string to wchar_t* (UNICODE), and you have the option to change the compiler to use char* instead. If you want to use standard char* strings then just disable the UNICODE feature.

> why they needed to make 2 types of strings, char string and w_char string?

A few years down the line, they realized that two types of strings are nowhere near enough; so now we have five.

std::string str = "hello world\n" ; // string where char_type is char
    std::wstring wstr = L"hello world\n" ; // string where char_type wchar_t
    std::string utf8str = u8"hello world\n" ; // utf-8 encoded UNICODE string
    std::u16string u16str = u"hello world\n" ; // utf-16 encoded UNICODE string
    std::u32string u32str = U"hello world\n" ; // utf-32 encoded UNICODE string

You might want to read this:
http://www.joelonsoftware.com/articles/Unicode.html

>> Your basic console mode "Hello, World!" program comes in around 6 K using stdio.h and printf and anywhere between 250 K - 500 K using iostream and std::cout.

what do you mean by K?

about the rest posts, i see no reason to change from using char to wchar_t, anyway, if someone wants support for other alphabets it means that he is dealing with a big/complex project(witch involve creating a GUI), so neither in such a project i see an advantage

what do you mean by K?

He means that the iostream library takes up more space in the executable than the stdio library after compilation. It's not an unreasonable concern, but shouldn't be the only concern when choosing between iostream and stdio.

i still prefer iostream over stdio.h because iostream is designed for all basic types of input and output, not only for console

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.