Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: Returning an array from a function (C)

    Okay. My programming skills are definitely lacking... could anyone help me with this? I was told that I could indirectly 'return' my array by just using pointers in my functions... but this could definitely be wrong. If anyone could show me what I need to do to get this to work, I'd really, really appreciate it!

    #include <stdio.h>

    void sieve(int prime[998]);

    int main(void)
    {

    int prime[998];
    int i;
    int j = 2;
    int k;

    for (i = 0; i = 997; i = i + 1)
    {
    prime[i] = j;
    j = j + 1
    }

    sieve(&prime[998])

    for (k = 0; k = 998; k = k + 1)
    If prime[k] > 0
    printf("%d ", prime[k]);

    }


    void sieve(int *prime[998])
    {
    int x;
    int y;

    for (x = 2; x = 31; x = x + 1)
    for (y = 0; y = 996; y = y + x)
    prime[y + x] = 0;
    }
    Last edited by Shownah; 03-21-04 at 21:07.

Posting Permissions

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