pointers and functions

hey guys so ive tried searching my problem and with some searching havent found an answer nor do i completly understand the issue it.
here is the code
#include "cmps222lib.h"
#include "functions.h"
#include "logger.h"

void SortAscending(int*Array,const int count);

void FillArrayWithRandom(int* Array,const int count,const int min,const int max);
// your functions or file includes

int main()
{
Logger::OpenLogFile("main.log");
int*Array;
const int count=10;
const int min=0;
const int max=count;
FillArrayWithRandom(Array, count, min, max);
SortAscending(Array, count);
// close the logfile and exit
Logger::CloseLogFile();
return 0;
}

i get error on line 23 saying array may be used uninitialized in this function.

ive tried playing with the pointer and the functions for it but to no avail.

heres the code for fill and array

#include "functions.h"

void SortAscending(int*Array,const int count) {
LogStart2(Array,count);
for(int loop=0;loop<count;loop++) {
for(int loop2=0;loop2<count-1;loop2++) {
Logger::Log("comparing and swapping as necessary");
if(Array[loop]<Array[loop+1]) {
swap(Array[loop],Array[loop+1]);
}
}
}
}

void SortDescending(int*, const int);

void PrintArray(const int* target,const int count);

void FillArrayWithRandom(int* target, const int count, const int min,const int max) {
for(int loop=0;loop<count;loop++) {
target[loop]=CreateRandomNumber(min, max);
}
}
if anyone could help i appreciate it

i have to use the void functions the teacher wont accept it anyother way . when i tried setting Array=CreateRandom it gives me another compiling error that void value not ignored
Last edited on
> i get error on line 23 saying array may be used uninitialized in this function.
It is.
int Array[42]; creates an array that may hold 42 elements, no element were initialized.
int *Array; creates a pointer that points to garbage. You didn't reserve any space, and it's completelly useless as any operation (except asignment) will give you undefined behaviour.
thank you i i was able to figure it out in tutoring today.
i would have used what you mentioned but our teacher doesnt allow it.
i appreciate the help though.
Topic archived. No new replies allowed.