C Sorting Primer Tutorial

C Sorting Primer Tutorial

C Sorting Primer Tutorial

As we have mentioned before, as with C String Function Timings Primer Tutorial as shown below, you don’t have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage, and we’d also like to add that Windows C programmers from the days of Microsoft C, who miss it (know I do … it was solid), can still write some of this code using Digital Mars C. Luckily, one of the most useful functions, as exemplified by the C code line below …


qsort((void *)argv, (size_t)argc, sizeof(char *), isbigger);

… qsort … is available in Digital Mars C, as it used to work in Microsoft C.

We show it in action today sorting, alphabetically, command line arguments (on the Windows (DOS) command line doh!). It has the scope, with its interface to tailoring your own sorting “algorithm” function abilities, to be able to handle any type of business logic you choose, that “sorting” jobs so often ask for.

So … get … sorted … with our C code you could call use_qsort.c based on an idea out of a Microsoft C manual and Digital Mars compilable via (the taxing chortle, chortle) …


dmc use_qsort

… yes … no make files required here, nor IDE menus … but brush up on your pointers, perhaps.

As a Windows programming afficianardo would tell you … desktop functionality opens you up to many scheduling and batch mode processing ideas often crucial to the best productivity tools in software. It is no wonder that the web’s curl is so popular so that a bit of these software strengths from the desktop days can be brought to bear on the web application world we increasingly encounter today.


Previous relevant C String Function Timings Primer Tutorial is shown below.

C String Function Timings Primer Tutorial

C String Function Timings Primer Tutorial

You don’t have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.

So it is today with this tutorial, where we work with Digital Mars C, to time some inhouse and C string library (string.h) library string manipulation functionality. If you get to compile (recommend Digital Mars C) and run this tutorial’s download at a Windows Command Line (prompt) you will see how fast C is, working way down there near the kernel level. So the second accuracy of time(NULL) won’t pass muster for the timings, and instead, here, we use the clock() functionality to get the refinement required to have it mean anything. Could be affected by so many other things anyway, like what else is running, but is instructive as to what you might have thought was the fastest method. Personally, love using strstr() to find strings within strings, but, as you can see from the numbers, there are better choices such as strchr() and strpbrk() … personally, I’m affronted, gobsmacked, insulted, resigned … impersonally, I’m anti-affronted, anti-gobsmacked, anti-insulted, anti-resigned … the nearby ants, antily-anti-affronted, antily-anti-gobsmacked, antily-anti-insulted, antily-anti-resigned.

So feel free to download the C programming source code here and rename it to timings.c

Hope you enjoy this tutorial showing you some command line C dmc (Digital Mars) compilation work.

A really helpful tutorial for code above to do with using clock() is shown here … thanks.

A really helpful tutorial for C string functionality via string.h is shown here … thanks.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , , . Bookmark the permalink.

9 Responses to C Sorting Primer Tutorial

  1. I together with my pals happened to become reading by the top assistance out of your net blog even though all of a sudden developed a terrible feeling I had not expressed respect to the blog owner for those tactics. These young males are already for that reason joyful to find out all of them and have now sincerely been loving them. We appreciate you genuinely really thoughtful after which for deciding on these kinds of decent subject matter a lot of people are truly eager to find out. Our honest regret for not expressing appreciation to you sooner.

  2. *An impressive share, I just given this onto a colleague who was doing slightly analysis on this. And he in fact bought me breakfast because I located it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading far more on this subject. If possible, as you become expertise, would you mind updating your weblog with much more details? It is highly valuable for me. Big thumb up for this blog post!

  3. Thank you, IÒ€ℒve recently been searching for info about this topic for ages and yours will be the greatest IÒ€ℒve located out so far. But, what in regards towards the bottom line? Are you certain concerning the supply?

  4. But wanna comment on few general things, The website design and style is perfect, the written content is very wonderful : D.

  5. program says:

    I have recently started a web site, the info you provide on this website has helped me tremendously. Thanks for all of your time & work.

  6. Excellent post. I previousally to spend alot of my time water skiing and watching sports. It was quite possible the best sequence of my past and your content kind of reminded me of that period of my life. Cheers

  7. ball says:

    Particularly valuable perspective, appreciate your sharing with us.. Unquestionably useful perception, many thanks for writing.. Loving the thread.. thanks a bunch Isn’t it awesome whenever you uncover a good post?

  8. Great awesome things here. I‘¦m very happy to see your article. Thanks a lot and i’m looking forward to contact you. Will you please drop me a mail?

  9. Dealer says:

    You can certainly see your skills within the paintings you write. The sector hopes for even more passionate writers like you who aren’t afraid to say how they believe. Always follow your heart.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>