Board logo

標題: 有沒有人知道這C++程式錯在那裡 [打印本頁]

作者: 花之慶次    時間: 2006-11-22 23:14     標題: 有沒有人知道這C++程式錯在那裡

#include<iostream>
#include<stdlib.h>
// The main() function
int main()
{
      wchar_t wc;       // wide char variable
      wc='b';            //assign 'b' to wc
      std:: wout << wc;   // display 'b'
      wc='y';            // assign 'y' to wc
      std:: wout << wc;   // display 'y'
      wc='e';            // assign 'e' to wc
      std:: wout << wc;   // display 'e'
      
      system("pause");
      return 0;
}


個人認為問題是出現在wout, 如果將 wout改為cout 會不會更好呢??
作者: d_chu    時間: 2006-11-23 12:58

I am not really good in c/c++.. may be wrong

I think the purpose of this exercise is meant to use 'wout' command instead of 'cout'. If this is the case, I think you need to include <stddef.h> lib.

wout is to display wide charcters, which is double size of char.

This is all I know about wout. hhl, do you have any idea? Thx

[ 本帖最後由 d_chu 於 2006-11-23 05:03 AM 編輯 ]
作者: hhl    時間: 2006-11-23 14:04

Very nice to have my name mentioned ~~~~~

Simply put to compiler to try, you will find out no need to have stddef.h included, just the iostream is enough.

Also, there is only wcout, no wout ...

Yes, wcout will support two byte char set, but don't know which coding table it is referencing, or depends on system, not sure ... i can only say the different of cout and wcout is the "cout" is to display "char*" and the "wcout" is to display "wchar_t*" in the programming view ~
作者: 花之慶次    時間: 2006-11-23 22:17

Thank You!!!
作者: d_chu    時間: 2006-11-24 14:05

thanks for the info, hhl..  havn't touch c++ for 5 years. it is already good for me to still remember a command like wout or wcout.

As also mentioned from you that wcout is double of char... so... correct me if I am wrong.. In practically, is it able to store character other than english, such as chinese (2 byte unicode)?
作者: hhl    時間: 2006-11-24 15:46

Of course ~ just use wchar_t, you can store 2bye unicode char using wchar_t, however, for display or print it, it is another thing ... more complicated ...
作者: friday505    時間: 2006-11-24 22:35

Learned good idea.
作者: 0078    時間: 2006-12-7 13:35

use and practice are good methods
作者: jayzhou_2046    時間: 2006-12-7 14:33

wout不是std鮡野,
但捃唔到相關髼eader file.

據講wout係出自Al stevens跟Clayton Walnum合著的The C++ Programming Bible.
作者: wengsiu    時間: 2006-12-25 00:53

Thanks for your knowledge. I will try it out..
作者: keen    時間: 2007-1-1 21:13

我感觉斑主学习编程有点走入误区
作者: tianyatianya    時間: 2007-1-15 21:00

wc='b';            //assign 'b' to wc
      std:: wcout << wc;   // display 'b'
      wc='y';            // assign 'y' to wc
      std:: wcout << wc;   // display 'y'
      wc='e';            // assign 'e' to wc
      std:: wcout << wc;   // display 'e

OK!
作者: gomaydir    時間: 2007-1-24 03:18

好东西 我喜欢 谢谢分享好东西 我喜欢 谢谢分享
作者: 花之慶次    時間: 2007-1-28 11:02

引用:
原帖由 keen 於 2007-1-1 21:13 發表
我感觉斑主学习编程有点走入误区
朋友, 你可不可以具體地告訴我??
作者: 花之慶次    時間: 2007-1-28 11:12

引用:
原帖由 jayzhou_2046 於 2006-12-7 14:33 發表
wout不是std鮡野,
但捃唔到相關髼eader file.

據講wout係出自Al stevens跟Clayton Walnum合著的The C++ Programming Bible.
你說得正確!!
因為這程式是不能執行




歡迎光臨 香港 Xocat Forum 討論區 (http://p.xocat.com/p/) Powered by Discuz! 6.0.0