Search:

Type: Posts; User: manav-II

Search: Search took 0.01 seconds.

  1. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    get host info

    /*
    * GET-HOST-INFO . C
    *
    * Get information for a host.
    */

    #include <stdio.h>
    #include <netdb.h>
    #include <arpa/inet.h>
  2. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    my day time server

    /*
    * M Y - D A Y - T I M E - S E R V E R . C
    *
    * Day time server. Uses port 13, needs root permissions to run!
    */

    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>...
  3. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    Kill a process by name (or command line): [Linux...

    Kill a process by name (or command line):
    [Linux specific may be]


    #include <stdio.h>

    int main(int argc, char **argv) {
    int pid;
    FILE *p;
    char buff[256];
  4. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    Thanks Mats. Yeah, I too noticed, that, my...

    Thanks Mats.
    Yeah, I too noticed, that, my formatting was too dense, and hard on eyes.
    But when I tidy up the code it becomes even harder to understand, the function that was fitting on one page...
  5. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    Not exactly. Just felt the need. For example in...

    Not exactly. Just felt the need.
    For example in Perl I could do this:


    my @lines = <FILE>;

    now in C I can get very close to that, by doing this:


    char **lines = read_lines(in, &count);
  6. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    sorry guys, just a copy/paste blooper :confused:

    sorry guys, just a copy/paste blooper :confused:
  7. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    linked list data structure and utility functions....

    linked list data structure and utility functions.


    /* Bugs? Please report :) */

    struct node {
    int item;
    struct node *next;
    struct node *prev;
    };
  8. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    postfix expression parser. /* * FIXME *...

    postfix expression parser.


    /*
    * FIXME
    * There may be bugs. Especially with the stack. Please report them.
    */
    static void postfix_err_die(char *p, int offset, char *msg) {
    ...
  9. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    thanks Mats, i will post a modified version...

    thanks Mats, i will post a modified version later.


    arithmetic expression parser.


    /*
    * This is an infix expression parser. The parser disregards the precendence of operators.
    * For...
  10. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    thanks for all the feedback. i had thought that...

    thanks for all the feedback.
    i had thought that to make it work for stdin, i can read all the input and save it to a file, so that the above method works.

    otherwise my approach would be:
    read a...
  11. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    read_line & read_lines from a FILE *

    read_line & read_lines from a FILE *


    /*
    * FIXME
    * Fails for stdin.
    * There may be bugs. Please report them.
    */
    char *read_line(FILE *in) {
    char *line;
  12. Thread: my C snippets

    by manav-II
    Replies
    20
    Views
    3,717

    my C snippets

    hope it helps someone. but will serve as a quick access for me.
  13. thanks to all! problem is fixed now.

    thanks to all! problem is fixed now.
  14. how to handle keyboard and mouse events for all windows

    Hi all,

    how to handle (or just get notified about) a keyboard or mouse event happened for any open window OR desktop itself.

    what I want to do is just run in a loop sleeping 1 second before...
  15. Replies
    2
    Views
    1,276

    Why this fails - confusing

    please see the comments in code, can someone tell me why it works this way and fails the other way. i was trying to access the elements of the enum nested inside Logger class...


    class Logger
    {...
Results 1 to 15 of 16