Results 1 to 5 of 5

Thread: สอบถามเรื่อง Function

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    2


    คืิอตอนนี้ เรียน C อยู่ครับ แต่ไม่ค่อยเข้าใจเกี่ยวกับเรื่องการใช้ function เท่าไหร่

    ถ้าเราเก็บข้อมูลไว้ใน array ใน function นึง เราจาเอามาใช้ในอีก function นึง ยังไงหรอคับ

    example

    void main()
    {
    calculate();
    show();
    }

    สมมุตว่า ข้อมูลอยุ่ใน array อยุ่ใน function calculate อ่ะคับ

    แล้วพวก ส่งค่า รับค่า คือยังไง คับ แอบ งง
    **Hidden Content: To see this hidden content your post count must be 1 or greater.**

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Posts
    13


    ตัวอย่างการเขียนฟังก์ชั่น
    แต่ผมไม่เข้าใจเรื่องอะเรย์เหมือนกัน

    example
    #include<stdio.h>
    int aa,bb;
    int calculate(int cc);
    void main()
    {
    scanf("%d",&aa);
    calculate(aa);
    show();
    }

    int calculate(int cc)
    {
    bb=cc;
    return 0;
    }

  3. #3
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    [code]

    int Calculate(int* pData, int num);
    void Show(int* pData, int num);

    void main()
    {

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Posts
    4


    ตัวอย่างนะครับ อันนี้ โมนิดหน่อย เพื่อ ให้เข้าใจง่าย


    **Hidden Content: To see this hidden content your post count must be 2 or greater.**



    ลองดูครับ ผมคอมไพล ด้วย bcc 5.5 commandline ใช้ได้แน่นอน

  5. #5


    มี 2 แบบ นะครับ

    array คือการเกบข้อมุล แบบ static
    LinkedList คือ เกบแบบ dynamic

    array แบบ ง่ายๆ

    #include <stdio.h>
    #include <conio.h>
    void sendToU(int[5]);
    void main()
    {
    int a[5] = {1,2,3,4,5};
    sendToU(a); // การส่ง ข้าม function นะครับ เรียกส่งผ่าน parameter (หรือเรียก argument ก้ได้)
    getch();
    }
    void sendToU(int xxx[5])
    {
    printf("%d",xxx[0]);
    printf("%d",xxx[1]);
    printf("%d",xxx[2]);
    }

Similar Threads

  1. สอบถามเรื่อง IPCOP ครับ
    By wachira in forum IT problem consult
    Replies: 2
    Last Post: 28-12-2008, 07:37 PM
  2. Replies: 0
    Last Post: 03-08-2007, 08:17 PM
  3. Replies: 0
    Last Post: 01-01-1970, 07:00 AM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •