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 > In desperate need of help!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-02-04, 15:44
Arashi90 Arashi90 is offline
Registered User
 
Join Date: May 2004
Posts: 1
Unhappy In desperate need of help!!

Hey guys, this is my first time posting here, but I've used the forums to find help before

I'm in a jam, my final C program is due and I still can't get it to work.

I'm trying to return an int array from a function to the main for use in other functions, but it won't let me return it.

Function Declaration:

Quote:
int calcFreq(int Ratings[], int Freq[], int NumStudents);
Function Call:

Quote:
Freq[] = calcFreq(Ratings, Freq, NumStudents);
Function Body:

Quote:
int calcFreq(int Ratings[], int Freq[], int NumStudents)
{

int i = 0;

for (i = 0; i < NumStudents; i++)
{
Freq[Ratings[i]-1] = Freq[Ratings[i]-1] + 1;
}
return Freq[];
}
Thanks for any help you can provide!
Reply With Quote
  #2 (permalink)  
Old 05-04-04, 18:15
avleyva avleyva is offline
Registered User
 
Join Date: Mar 2004
Posts: 8
Exclamation You have a small error

Your function calcFreq does not return an array, I recommend you to return a 0 or -1 to indicate error/success instead of trying to return an array:

return Freq[]; /* this is wrong */

return 0; /* this is wright */
return i; /* this is wright */
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