Thread: Cool/nifty things to do with C?

  1. #1
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413

    Cool/nifty things to do with C?

    I got back into C programming because I wanted to see how hard it would be to make a sound file from scratch, which isn't that hard, even without libraries (depends on the type though). I'm not as good as I want to be though. I've been picking up tips and tricks from you guys for the past month or so and now I'm looking for small projects to do to increase my C knowledge. What are some small nifty projects you've done in C? I know abachler made a CD/DVD burner in like 20-30 lines of code, that was pretty cool.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Epy View Post
    I know abachler made a CD/DVD burner in like 20-30 lines of code, that was pretty cool.
    It's an ISO image ripper, it doesn't burn the CD or operate any hardware.

    Depends what you mean by small. I did this last week when I was mirroring a site with wget and it took like 5 hours. See: text and manpage viewer for linux (my big project) will continuously "tail" a log file, that is, update the display at intervals as the file grows. But as I discovered, if the file is growing very very rapidly (like a wget log), it never catches up by the time the text makes it into the GUI (have to work on that...). So a crude text terminal method:
    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[]) {
            int bz = atoi(argv[2]);
            char buf[bz];
            FILE *in = fopen(argv[1],"r");
            if (!in) {
                    perror("fopen: ");
                    return 0;
            }
    
            for (;;) {
                    while (fgets(buf,bz,in)) {
                            printf("%s",buf);
                    }
                    sleep(1);
            }
    
            return 0;
    }
    I think you can see what happens here (the args are the filename, and the max line length).

    Of course, that is not really much of a project I liked writing a packet sniffer, if you are looking for something with some use value (now wifi is everywhere). 3D (openGL) graphics has an immediately gratifying angle to it, the API is fairly challenging.

    But really -- learning a GUI API is great, because it opens up a lot of opportunities. After I finished downloading that site, I used this:

    gdirtree.c

    (there's a bunch of my old projects in that directory, some of them are sorta embarrassing )

    It gives you a collapsable listing of an entire directory tree, including the total size and number of files, plus the same for each for each subdirectory (recursively).

    I've also used gtk to add an interface to openGL stuff. So yeah, I would think of something you'd like out of that, pick an API, and start learning.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Been meaning to "pick" a GUI API...so many choices. I was going to learn FLTK but that's C++.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by MK27 View Post
    It's an ISO image ripper, it doesn't burn the CD or operate any hardware.
    Oh yeah and that's not hard at all really if you've ever done any file I/O. I wrote a floppy ripper once, unused sectors and all.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Funny things happening outside of function
    By drb2k2 in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 02:26 PM
  3. things to think about... [from www.nuclearwastesite.com]
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-11-2001, 12:47 AM
  4. What is your favorite things about programming?
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 10-21-2001, 12:13 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM