列印程式HELLOWORLD

2021-06-07 14:36:04 字數 991 閱讀 2483

#includehdc getprinterdc(void)

int winapi winmain (hinstance hinstance, hinstance hprevinstance,

lpstr lpszcmdline, int icmdshow)

; di.cbsize=sizeof(docinfo);

di.lpszdocname=text("test");

hdc hdcprint=getprinterdc();

if(hdcprint!=null)

deletedc(hdcprint);

} }return 0 ;

}

安裝的虛擬印表機是smartprinter

對於上面出現問題的解決

這個問題是由於前後使用的字元不一樣導致的,前面是寬字符集wchar_t*,後面是char*型別計算的,所以

更改如下

textout(hdcprint,240,190,text("這是我的第乙個列印程式"),sizeof(text("這是我的第乙個列印程式"))/2);

因為乙個unicode字元是兩個位元組的,所以這裡要除以2

這樣,後面出現的奇怪字元就不會出現了

如果未使用unicode字元,那麼

textout(hdcprint,240,190,text("this is my first printer hello world"),sizeof("this is my first printer hello world"));

不用除以2就可以完整列印,而不會出現奇怪字元

好了,helloword到此列印結束

mips彙編列印 hello world

mips組合語言列印 hello world 字串。已在pcspim下編印通過 print hello world programed by stevie zou text segment text globl main main la a0,str a0儲存要列印字元的位址 li v0,4 為sy...

C語言列印「Hello World「

include 包含標準庫的資訊 main 定義名為 main的函式,他不接收引數值 下面對程式本身做以說明 乙個c語言程式,無論大小如何,都是由函式和變數組成的,函式中包含一些語句,以指定所要執行的計算操作 變數則用於儲存計算過程中使用的值。在本例中,函式的名稱為main 通常情況下,函式的變數名...

彙編helloworld程式

data segment 定義資料段 output db hello world 定義乙個字串,記得要以 為結束標誌 data ends 資料段結束 code segment 段定義開始 assume ds data,cs code start mov ax,data 實現段位址datas載入到ds...