การรับค่าเป็น ID number,name,address,salary

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

ABout

การรับค่าเป็น ID number,name,address,salary ของพนักงาน 5 คน

Code ตัวนี้ compile ไม่ได้


1 #include 2 #define REC 5 3 main() { 4 struct { 5 char nn; 6 char code[5]; 7 char name[25]; 8 char addr[30]; 9 int salary; 10 } biodata[REC]; 11 clrscr(); 12 int i,sum=0; char c; 13 printf(“Please for input 5 record : “); 14 for(i=0;i

35 }

Error Message from software “turbo c v.2.01”

compiling error line 12 : Expression syntax in function main error line 14 : undefined symbol ‘i’ in function main error line 15 : non-portable pointer conversion in function main error line 25 : undefined symbol ‘sum’ in function main error line 29 : undefined symbol ‘c’ in function main


โปรดดูให้หน่อยว่าผิดตรงใหนอะ

ABout (C Programming) เกี่ยวกับภาษาซี

post รอบ 2 เพราะอ่าน post รอบ 1 ไม่ออก

การรับค่าเป็น ID number,name,address,salary ของพนักงาน 5 คน

Code ตัวนี้ compile ไม่ได้

=========================================

1 #include

2 #define REC 5

3 main() {

4 struct {

5 char nn;

6 char code[5];

7 char name[25];

8 char addr[30];

9 int salary;

10 } biodata[REC];

11 clrscr();

12 int i,sum=0; char c;

13 printf(“Please for input 5 record : “);

14 for(i=0;i

15 gets(biodata[i].nn);

16 printf(“record # %d : “,i+1);

17 printf(“code : “);

18 gets(biodata[i].code);

19 printf(“name : “);

20 gets(biodata[i].name);

21 printf(“address : “);

22 gets(biodata[i].addr);

23 printf(“salary : “);

24 scanf(“%7d”,&biodata[i].salary);

25 sum=sum+biodata[i].salary;

26 printf(“\n”);

27 }

28 printf(“Press any key to list \n”);

29 c=getch();

30 printf(“CODE NAME ADDRDSS SALARY \n.”);

31 for(i=0;i

32 printf(“%-5s %-25s %-25s %7d \n”,biodata[i].code,biodata

[i].name,biodata[i].addr,biodata[i].salary);

33 printf(” sum of salary = %7d \n”,sum);

34 c=getch();

35 }

=========================================

Error Message from software “turbo c v.2.01”

compiling

error line 12 : Expression syntax in function main

error line 14 : undefined symbol ‘i’ in function main

error line 15 : non-portable pointer conversion in function main

error line 25 : undefined symbol ‘sum’ in function main

error line 29 : undefined symbol ‘c’ in function main

=========================================

โปรดดูให้หน่อยว่าผิดตรงใหนอะ

sugree's picture

ตามที่มันบอกละครับ โค้ดข้างบนมีการประกาศตัวแปรหลังจากทำไปแล้วหนึ่งคำสั่ง clrscr() นอกนั้นคงหาง่ายแล้ว

thank you very much , ลืมสังเกตอะ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น