Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_VALUE = 6;
#define MIN_VALUE = 1;
const int NUMBER_OF_VALUES =(6 - 1 + 1);
const int NUMBER_OF_TRIALS = 1000;
int main()
{
int count[NUMBER_OF_VALUES];
int i;
int value = i + MIN_VALUE;
for (i=0;i<NUMBER_OF_TRIALS;i++)
{
int position;
int random;
double randomReal;
randomReal = rand()/(((double)RAND_MAX)+1)) * NUMBER_OF_VALUES + MIN_VALUE;
random = (int)(randomReal);
position = random - MIN_VALUE;
count[position] = count[position]+1;
}
printf("Counts\n");
for (i=0;i<NUMBER_OF_VALUES;i++)
{
printf("%d : %d\n",(value), count[i]);
}
int expectedCount;
expectedCount = NUMBER_OF_TRIALS/NUMBER_OF_VALUES;
printf("The expected count is %d\n",expectedCount);
printf("Distance From Average\n");
for (i=0;i<NUMBER_OF_VALUES;i++)
{
int distanceFromExpected;
distanceFromExpected = count[i] - NUMBER_OF_TRIALS/NUMBER_OF_VALUES;
printf("%d : %d\n",(value),abs(distanceFromExpected));
}
}
Every time I try to run it, I get these errors:
Code:
**** Build of configuration Release for project RandomNumberCheckerInC ****
make all
Building target: RandomNumberCheckerInC
Invoking: GCC C Linker
gcc -o"RandomNumberCheckerInC" ./randomNumberChecker.o
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 20
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [RandomNumberCheckerInC] Error 1
Which I figure to mean that there's no main method but I clearly have a main method in my program. I'm just a beginner C
programmer using Eclipse to build and run my code. Why won't my current code work correctly?