Jump to content
  • Advertisement
Sign in to follow this  

Getting an error with array or pointer type!

This topic is 5068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

/* this program sort numbers, note: not names of the game players; 
   even though each player has their own name, this program focuses 
   more on sorting each players' scores alone with their desire name, 
   to see what game player got the highest scores in the game of skating */

#include <stdio.h>  // basic input and output functions

// function procedure to get basic data of player
// return void to return nothing, remember astronauts program
// problem was this one getting error returning a value.
void getdata(char skaters[][15], double scores[][6]);
void averages(char skaters[][15], double scores[][6], double average[]);
void bubblesort(char skaters[][15], double average[], char *pointer[], double *decimal[]);

// our main program global function
int main()

// initialize all the necessary variables needed
// major variables are: skaters[][], scores[][], 
// average[][], *pointer[][] and *decimal[];
char skaters[11][15]={0}, *pointer[11];
double scores[11][6]={0}, average[11]={0}, *decimal[11];

// getdata function procedure to prompt the user
// for the name of each skaters' scores 

// average function procedure to average all the 
// six scores from all 10 skaters

// bubblesort function procedure to sort all the 
// six scores by averages in descending order

// return 0 if compile successfully
return 0;
// getdata function procedure for getting each skaters'
// name and six scores.
void getdata(char skaters[][15], double scores[][6])
// create a variable that would count the number of times
// the for...loop should pass. In our case 10 names and
// 6 scores for each skater.
 int count=0;

  printf("\nEnter the names of the #%d skaters: ",count);
  printf("\nEnter the scores of %s: ",skaters[count]);
  scanf("%f %f %f %f %f %f",&scores[count][1], &scores[count][2], 
  &scores[count][3], &scores[count][4], &scores[count][5], 

// average function procedure to get the skater's 
// average score out of all six scores.
void averages(char skaters[][15], double scores[][6], double average[])

// to total the average of the six scores first we eliminate 
// the high and low scores by finding out which is the highest and lowest 
// score of the skater.
 int count=0,j=0;
 double total={0};

// here we initialize the high score and low scores by the first number 
// of that the skater has.
	 double high=scores[count][1];
	 double low=scores[count][1];

// initialize for...loop to determine high and low scores
// this is a simple formula or algorithm.

// compare second number of the skater by the varible low or first score.  
// If the second score is less than first, assign the second
// score to the variable low.  Loop...Until you get to the 
// lowest score possible.
		 if(scores[count][j] < low)
			 low = scores[count][j];

// if second score is higher than the first score then initialize 
// second score to the variable high, keep looping through all 
// six scores to determine which one is the highest score.
		 if(scores[count][j] > high)
			 high = scores[count][j];

// add all six scores of the skater.
		 total = total + scores[count][j];

// eliminate the high score and the lowest score.
	 total = total - low - high;

// get the average of all the six scores by dividing
// the total scores by 4, because we have eliminated 
// two of them, the highest and lowest scores.
	 average[count] = (total / 4);


void bubblesort (char skaters[][15], double average[], char *pointer[11], double *decimal[11])
	int flag=1, count=0;
	int final = 10 - 1;

		pointer[count] = &skaters[count][0];

		decimal[count] = &average[count][0];


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!