PDA

View Full Version : ใครที่เคยใช้ visual c++ ช่วยเข้ามาดูให้หน่อยครับ พอดีเขียนโป



Tony
05-12-2004, 02:55 AM
ผมเขียนใน Microsoft Visual C++6.0 ครับแต่เขียนเป็นภาษาซีโปรแกรมผมจะเป็น เช่น Test.c ตอนผมเขียนโปรแกรมธรรมดา ที่ใช้แค่ #include "stdio.h" ก็ complie ได้ปกติครับ แต่พอเขียนโปรแกรมที่ ต้องใช้ getch,clrscr, ดังตัวอย่างละครับ ทำไมไม่ผ่าน ต้องแก้ไขอย่างไรครับ รบกันผู้รู้แนะนำด้วยนะครับ ว่ามันเกิดจากอะไร แก้อย่างไรครับ
#include "stdio.h"
#include "conio.h"
void main()
{
char ch;
clrscr();

printf("Enter Charactern:");
ch=getch();
printf("nDisplay%c",ch);

getch();
}
ส่วนที่ฟ้อง error ครับ

--------------------Configuration: to - Win32 Debug--------------------
Linking...
to.obj : error LNK2001: unresolved external symbol _clrscr
Debug/to.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

to.exe - 2 error(s), 0 warning(s)

asylu3
05-12-2004, 09:26 PM
#include < stdio.h >
#include < conio.h > //need for system();
#include < stdlib.h > //need for system();

int main()
{
system("cls"); // ใน windows ใช้คำสั้งนี้แทน clrscr()
printf("hello worldn");

}

Anonymous
18-12-2004, 06:10 PM
standard C runtime library ใน VC++ ไม่มีฟังก์ชันเหล่านี้อีกต่อไปแล้วคับ เช่นพวกฟังก์ชัน clrscr(), textcolor() และอื่นๆ ซึ่งเคยเป็นฟังก์ชันที่เคยมีอยู่ใน compiler ตัวอื่น เช่น Turbo C

ฟังก์ชันเหล่านี้ (โดยเฉพาะที่ประกาศอยู่ใน conio.h) ไม่เป็นไปตามมาตรฐาน ANSI/ISO C/C++ ด้วยครับ หากใช้ก็ต้องระวังเรื่อง compatibility ด้วยคับผม