If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Returning an array from a function (C)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-04, 19:15
Shownah Shownah is offline
Registered User
 
Join Date: Mar 2004
Posts: 1
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 20:07.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On