User Profile

Collapse

Profile Sidebar

Collapse
jjdot
jjdot
Last Activity: Mar 17 '11, 08:22 AM
Joined: Feb 28 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jjdot
    replied to How to print address of enum?
    in C
    enum are not variables. They are constant value not constant variables ! A variable has a memory address;
    a constant, no. What you try to do is the same that trying to get the address of 2.
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to How to grep from line n1 to line n2 in a file?
    awk '{ if (n1 <= NR && NR <= n2) print NR $0; }' yourfile | grep expression
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to Why main() works also only with argc but not argv?
    in C
    It is a good summary but to prevent portability problems
    you should use either 3 or 4 forms.
    See more | Go to post

    Leave a comment:


  • Because the parent process of your program calls it with
    the 3 arguments by convention ! You can write for instance:

    Code:
    struct t {
      double x;
    };
    
    int main(struct t t)
    {
      return 0;
    }
    Your compiler should accept this program (perhaps with
    a warning). Then if you execute your program:

    myprog bla bla arg!

    Who knows how to convert arguments...
    See more | Go to post

    Leave a comment:


  • You can have a third argument that contains environment
    variables; it is a NULL terminated array of strings.

    int main (int argc, char **argv, char **env);

    I had never seen any program using it. Perhaps because
    you have to parse yourself strings in 'env'. Each string
    has the form VARNAME=VALUE. The function 'getenv' is more
    convenient to check the value (and even existence) of an
    environment...
    See more | Go to post

    Leave a comment:


  • Main is guessed to receive (at least) 2 arguments. Even if you can declare it with less arguments, the main function is called with the number of arguments and the array of arguments as parameters. Thus if 'main' is declared with
    only 1 parameter this one receives (up to a cast) the number of arguments. In your second example, argv is assigned the number of arguments (+1 for the command name). So *argv[0] reads at address 1 which yields the...
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to What functions to use to create a webserver?
    in C
    Perhaps that GNU libmicrohttpd will interest you:
    http://www.gnu.org/software/libmicrohttpd/...
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to Continue statement not within loop?
    in C
    remove the semi-colon at the end of first line
    Code:
    while(fscanf(records,...
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to What is u_int32_t?
    in C
    Ok. I'ignored existence of this type. In fact I always
    use stdint.h. I found u_int32_t definition in header file
    #include <sys/types.h>

    I think the simplest way to do is to
    #include <stdint.h>
    #define u_int32_t uint32_t
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to What is u_int32_t?
    in C
    It is uint32_t and not u_int32_t. Normally you just have
    to include:

    #include <stdint.h>

    on a 32 bits machine you can replace it by
    #define uint32_t unsigned int
    on a 64 bits machine I think you should work too but.
    See more | Go to post

    Leave a comment:


  • jjdot
    replied to Caesar Cipher in C Help
    in C
    I think you should enable all warning messages of your compiler. gcc -Wall used on your program gives:

    t.c:16:1: warning: suggest parentheses around assignment used as truth value
    t.c:17:1: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning
    t.c:21:1: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning
    t.c:16:4: warning: suggest explicit...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...