Search:

Type: Posts; User: coder222

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    5
    Views
    7,740

    Now I need to write a version of getword that...

    Now I need to write a version of getword that properly handles underscores, string constants, comments or preprocessor control lines. I just don't understand now how to process, I would be looking...
  2. Replies
    5
    Views
    7,740

    Something like this, perhaps? int...

    Something like this, perhaps?




    int getword(char *word, int lim)


    {
    int c, getch(void);
  3. Replies
    5
    Views
    7,740

    getword function

    Hello, I don't obviously understand how this function works:




    int getword(char *word, int lim)


    {
    int c, getch(void);
  4. Thread: Program help

    by coder222
    Replies
    6
    Views
    756

    I'm confused. How can I attempt the exercises if...

    I'm confused. How can I attempt the exercises if the code presented in the book doesn't even compile?
  5. Thread: Program help

    by coder222
    Replies
    6
    Views
    756

    It should convert a C declaration into words,...

    It should convert a C declaration into words, like this:

    char ** argv
    argv: pointer to pointer to char

    The program can also be found here <LinkSnippedDueToCopyright>

    I need to get...
  6. Thread: Program help

    by coder222
    Replies
    6
    Views
    756

    When I enter a declarator, for example char**argv...

    When I enter a declarator, for example char**argv produces the error message:

    syntax error
    c: c
    syntax error
    c: c
    syntax error
    c: c
  7. Thread: Program help

    by coder222
    Replies
    6
    Views
    756

    Program help

    So now I'm working with the K&R code again and trying to get it work successfully. Any help is appreciated to get this working, thanks.

    here is the code:




    #include <stdio.h>
    #include...
  8. Replies
    1
    Views
    5,406

    gettoken() function

    hello,

    I have been trying to understand this function, there is still a few things confusing me. First, what are those weird statements like return token type = BRACKETS for? I have never seen...
  9. Replies
    0
    Views
    1,112

    gettoken() function from K&R

    Hello, I came across this function when reading the K&R and here is my comments on the source. Am I on the right track? Also, I'm not sure what is ungetch here or how it's supposed to work.




    ...
  10. Thread: Snake game

    by coder222
    Replies
    2
    Views
    1,583

    Snake game

    Hello, I would like to make a snake game. Here is what I have in mind:




    struct dot // snake position
    {
    int x;
    int y;
    }
  11. Thread: Parsing

    by coder222
    Replies
    2
    Views
    491

    Sorry, I did not provide enough information. The...

    Sorry, I did not provide enough information. The book I'm currently reading never goes over the Spiral rule. I think it is possible to parse declarations according to this grammar?

    dcl: ...
  12. Thread: Parsing

    by coder222
    Replies
    2
    Views
    491

    Parsing

    Hi,

    My C programming continues as I'm trying to understand complicated declarations.
    Can anyone point out how to parse a declaration like this:

    char (*( *x() )[] ) ()

    Or what is the general...
  13. Replies
    0
    Views
    374

    K&R Exercise 11

    Hello, I'm doing the K&R again.

    So what I need is some sort of help with this exercise:

    Modify the program detab to accept a list of tab stops as argument.
    Here is what I think it should go...
  14. Replies
    2
    Views
    1,596

    Thank you @Salem. Can you be more detailed about...

    Thank you @Salem. Can you be more detailed about the code that should be written? It's a bit of time I have written the above code, and my C programming is also rusty (Not to mention the breaks that...
  15. Replies
    2
    Views
    1,596

    Kernigan and Ritchie Exercise 5-11

    Here is the description: Modify the program detab (written as exercises in Chapter 1) to accept a list of tab stops as arguments. Use the default tab settings if there are no arguments.

    What I...
  16. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    @Anduril great explanation. Here is a simple test...

    @Anduril great explanation. Here is a simple test driver: http://coliru.stacked-crooked.com/a/db0fdb9ca3173168
    I mean simple, no error handling or anything but I think it shows that my function is...
  17. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    I think this is in other words what Anduril said:...

    I think this is in other words what Anduril said:



    What is actually happening here I'm dereferencing the pointers that are passed to the function so that I get copies of them and can modify...
  18. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    @Whiteflags: Perhaps this is what you...

    @Whiteflags:

    Perhaps this is what you intended?




    for (n = 1; n < argc && argv[n][0] == '-'; ++n) {
    switch (argv[n][1]) {
    case 'n':
  19. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    printf("numeric = %d, reverse = %d\n", numeric,...

    printf("numeric = %d, reverse = %d\n", numeric, reverse);

    while(argc > 1 && argv[n][0] == '-') /* Printf statements inside while loop? */
    switch(argv[n][1]) { ...
  20. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    Yes. It prints the arguments in the order in...

    Yes. It prints the arguments in the order in which they appear to, and doesn't do any sorting. For example,

    argc = 1, n = 0
    argv[0] = './fast'


    defghi
    abcd
    efg
  21. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    I haven't made any table yet, this is the right...

    I haven't made any table yet, this is the right way to go for the command line arguments?




    while(argc > 1 && argv[n][0] == '-')
    switch(argv[n][1]) {
    case 'n':
    ...
  22. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    So I plan to do the flag parsing myself....

    So I plan to do the flag parsing myself. argv[n][0] or *argv[0] is the first character of an argument string. That's why I changed line 34 to argv[n][1] in the switch statement.



    I'm afraid I...
  23. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    I'm not getting the reverse flag work please help...

    I'm not getting the reverse flag work please help here is my updated code:




    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
  24. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    > I also compile with maximum warning level and...

    > I also compile with maximum warning level and don't get any error/warning.

    This is what I came up with the comparison function:





    int lexiographic_descending_sorter (const char *s1,...
  25. Thread: Sort program

    by coder222
    Replies
    21
    Views
    1,773

    Sort program

    The task is as following: Modify the sort program to handle a -r flag, which indicates sorting in reverse (decreasing) order. Be sure that
    -r works with -n.

    I think the interest is the fourth...
Results 1 to 25 of 69
Page 1 of 3 1 2 3