推介:| 觀塘外賣速遞 | 將軍澳外賣速遞 | Party 美食到會 | 汽車蓬頂維修翻身 | 雪地靴 | 羊毛鞋 | 羊毛鞋墊 | Online Food Ordering System | Pre Wedding Photographer |

發新話題
打印

有沒有人知道這C++程式錯在那裡

有沒有人知道這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 會不會更好呢??

TOP

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 編輯 ]

TOP

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 ~

TOP

Thank You!!!

TOP

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)?

TOP

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 ...

TOP

Learned good idea.

TOP

use and practice are good methods

TOP

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

據講wout係出自Al stevens跟Clayton Walnum合著的The C++ Programming Bible.
IT代工/鎗手一名!
小弟並唔平, 但絕唔係貴!

TOP

Thanks for your knowledge. I will try it out..

TOP

我感觉斑主学习编程有点走入误区

TOP

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!

TOP

好东西 我喜欢 谢谢分享好东西 我喜欢 谢谢分享

TOP

引用:
原帖由 keen 於 2007-1-1 21:13 發表
我感觉斑主学习编程有点走入误区
朋友, 你可不可以具體地告訴我??

TOP

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

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

TOP

發新話題


重要聲明:本討論區是以即時上載留言的方式運作,本網站對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。本討論區有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿撰寫粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。


Copyright 1997- Xocat. All Right Reserved.