Hi,
I'm currently having big trouble with simple program, the job is to input the data (only integers) from user until he type dot ('.'), than store this integers in DYNAMIC array and finally sort it in ascending order.
I'm having trouble dealing with DYNAMIC array, all these pointers. And so on.
Here's my attempt:
Can you correct my code ? I can't make it workCode:#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int size=0; // size of array int *array; int *n, *m; // first element of array and last element of array int i; int o=0; do { scanf("%d", &tab[o]); size++; o++; }while(getchar()!='.'); array=(int*)malloc(n*sizeof(int)) // allocating memory; n=array // address of first element of array m=array+n*sizeof(int) // address of last element of array qsort(array); //DISPLAYING ARRAY AFTER SORTING for(array, array<(m); array=array+sizeof(int) { printf("Value is: %d", *i); } return 0; }![]()
Any further explanation why or for what reason is highly desirable.



LinkBack URL
About LinkBacks




