i am a beginner, i got linear search working quite fast.. but then total stuck.
i tried to write function test, that gives me some random numbers and sort them.
I watched all the videos and thought i understood how points work , but apparently not.
I dont even get the array pointer working right and fill it with the random numbers. (I get a core dumb )
Here is my code:
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int n = GetInt();
int* array[n];
int i;
for (i=0; i<n;i++)
{
*array[i]= rand();
printf("Eingabe: %d : %d\n",i,*array[i]);
}
}
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
void sort(int* array[], int x)
{
int i;
int counter;
do
{
counter = 0;
for (i=0;i<x; i++)
{
if (array[i]>array[i+1])
{
swap(array[i], array[i+1]);
counter = 1;
}
}
}
while (counter==1);
}
I hope someboby has mercy and gives me some advice or tip or hint... i sooooo wanna learn programming. so i would hate to have to give up so early :(