qsort Questions

3

Solved

I'm getting weird results from trying to use qsort on this array of structs. I have this struct: struct access_data{ int sector; int arrival_time; int checked; int processed; }; I construct...
Bonnette asked 15/5, 2014 at 22:23

3

Solved

I'm trying to use qsort to sort a character array. I can't see why this is not working. I have a pointer to the compare function as the man pages specifies. Can someone please tell me what's wrong?...
Huskamp asked 18/4, 2014 at 4:52

1

Solved

In C++, there are two versions of qsort() provided by the standard library: extern "C" void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); extern "C++" void...
Dressingdown asked 22/2, 2014 at 13:57

2

Solved

I'm trying to use qsort to sort a 2D array in C. The sort works, but I get the warning: warning: initialization discards 'const' qualifier from pointer target type [enabled by default] How can I ...
Whiteeye asked 22/9, 2013 at 18:39

3

Solved

I am using qsort library function to sort an array of structure elements, while searching on the Internet I found a resource: INFO: Sorting Structures with the C qsort() Function @ support.microsof...
Cates asked 22/7, 2013 at 8:9

5

Solved

I want to use qsort function to sort the characters in the strings using C++. #include<iostream> #include<string> #include<cstdlib> using namespace std; int compare_str(void co...
Crouton asked 20/7, 2013 at 2:26

2

Solved

I'm writing a loadable kernel module and I need to use the function qsort() which apparently cannot be used in kernel space. Is there a function that I can use that has a similar functionality ? ...
Omen asked 18/6, 2013 at 17:32

2

Solved

The following is my code and Qsort produces strange result: #include <stdio.h> #include <stdlib.h> char values[] = { 0x02,0x04,0x0b,0x16,0x24,0x30,0x48,0x6c}; int compare (const void ...
Electromechanical asked 11/4, 2013 at 5:59

1

Solved

I'm trying to learn c++ and was trying using sort and qsort. sort() works just fine but qsort doesn't, I don't know why, so can you help me please this is the code I was trying to compile #includ...
Dioecious asked 6/9, 2012 at 20:54

3

Solved

my problem is the next (is an easy example to show the problem): I have: int* array1; double* array2. array1=new int[10]; array2=new double[10]; array1=filledWithIntegers(random); array2=filled...
Movement asked 14/5, 2012 at 14:4

2

Solved

I am trying to figure out how to sort a multidimensional data (5 dimensions) in C. I know that using a 5d array is a solution that, from reading others posts on SO about this topic many folks find,...
Ideational asked 30/3, 2012 at 3:52

5

Solved

I'm tasked with the user inputting n lines containing a month, day and year in the form of 'January 12 99'. I have to sort the list of dates chronologically using qsort first by year, then by day,...
Salcido asked 8/3, 2012 at 12:19

6

Solved

This is from a 'magic' array library that I'm using. void sort(magic_list *l, int (*compare)(const void **a, const void **b)) { qsort(l->list, l->num_used, sizeof(void*), (int (*)(const v...
Claymore asked 8/9, 2011 at 20:44

4

Solved

This quicksort is supposed to sort "v[left]...v[right] into increasing order"; copied (without comments) from The C Programming Language by K&R (Second Edition): void qsort(int v[], int left, ...
Bergius asked 26/6, 2011 at 21:45

4

Solved

std::sort swaps elements by using std::swap, which in turn uses the copy constructor and assignment operators, guaranteeing that you get correct semantics when exchanging the values. qsort swaps e...
Caviness asked 30/5, 2011 at 10:11

2

Solved

Some preface: I'm a computer engineering student taking a first class in C after 3 semesters of Java (up to data structures). This question is in relation to a homework assignment, but a few steps ...
Outrigger asked 20/3, 2011 at 19:8

9

Solved

I've read that qsort is just a generic sort, with no promises about implementation. I don't know about how libraries vary from platform to plaform, but assuming the Mac OS X and Linux implementatio...
Langouste asked 31/7, 2010 at 20:43

2

Solved

I wrote my comparison function int cmp(const int * a,const int * b) { if (*a==*b) return 0; else if (*a < *b) return -1; else return 1; } and i have my declaration int cmp (const int *...
Monomerous asked 1/4, 2010 at 15:49

3

Solved

I have a structure: struct pkt_ { double x; double y; double alfa; double r_kw; }; typedef struct pkt_ pkt; A table of these structures: pkt *tab_pkt; tab_pkt = malloc(ilosc_pkt * sizeof(...
Gasbag asked 29/11, 2008 at 19:30

© 2022 - 2024 — McMap. All rights reserved.