Search:

Type: Posts; User: Joshun

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    2,474

    I have now completed my parsing program / library...

    I have now completed my parsing program / library (hopefully not too many bugs!), available at:
    https://github.com/Joshun/simple-parser

    With that finished, I can carry on with the game I was...
  2. Replies
    6
    Views
    2,474

    Solution:

    At last, found the solution. Line 25 of my code should instead read:



    while( check_char(buffer, &position) ) {


    The function must have been unable to read the full range of the char array...
  3. Replies
    6
    Views
    2,474

    Barney McGrew - thanks for the reply, I normally...

    Barney McGrew - thanks for the reply, I normally try to avoid using scanf but at least it works.

    std10093 - thanks, honestly didn't realise that. Does it initialise the whole buffer though?
  4. Replies
    6
    Views
    2,474

    Simple file parser

    Hi,
    I am writing a simple file parser for use in another project (for config file). The trickiest thing seems to be skipping unwanted characters (comments, spaces). It works partly, but after the...
  5. Replies
    11
    Views
    66,020

    How exactly would you implement this? Your...

    How exactly would you implement this? Your suggestion earlier (
    poll_set[fd_index] = poll_set[numfds-1];) didn't work, some of the clients aren't closed properly giving broken pipe errors. The only...
  6. Replies
    11
    Views
    66,020

    Would that not have exactly the same effect as ...

    Would that not have exactly the same effect as

    poll_set[fd_index] = poll_set[fd_index + 1];

    EDIT: in fact your suggestion gives broken pipe errors. what seems to work, in full, is


    ...
  7. Replies
    11
    Views
    66,020

    Thanks for the advice, I'll take out maxfd since...

    Thanks for the advice, I'll take out maxfd since it is no longer needed, and will sort out indentation with indent or astyle.

    I've changed the code so it only moves the last one into the free...
  8. Replies
    11
    Views
    66,020

    Seems to work

    I've experimented a bit and tried what you have suggest, I also realised that I forgot to initialise the struct.

    It seems to work :redface: I just hope there isn't some strange error still lurking...
  9. Replies
    11
    Views
    66,020

    I've checked the indentation, and whilst it may...

    I've checked the indentation, and whilst it may look slightly confusing the braces appear to be where they should be. The server's socket for incoming connections is always open, so vart what you...
  10. Replies
    11
    Views
    66,020

    Sockets using poll()

    Hi,
    Until recently I have been using select() to wait for activity on file descriptors, however this seems less efficient than poll. I rewrote the program using poll:

    Server:

    #include...
  11. Replies
    7
    Views
    22,347

    Thanks for the replies std10093, anduril462 and...

    Thanks for the replies std10093, anduril462 and c99tutorial, I finally get what you mean now - all the char pointers point to the same data. I used
    malloc(20) because a char is always guaranteed to...
  12. Replies
    7
    Views
    22,347

    Pass array of char pointers by reference

    Hi,
    I am building a program with an index of strings (char pointers). So far I have created an array 10 char pointers using



    char *index[10];
    int i;
    for(i=0; i<10; i++)
    {
    ...
  13. Replies
    2
    Views
    2,668

    Creating / receiving timers

    Hi,

    Please could someone explain this simple timing code (to be used under Linux). I get most of it, but some of the struct members like sa_flags confuses me and I can't find something that...
  14. Replies
    10
    Views
    4,664

    Ok thanks, I have finally sorted out the issues...

    Ok thanks, I have finally sorted out the issues with the \n's. I have also added a function to interpret a 'take' command, which copies the first 5 characters after the word 'take ' from the prompt...
  15. Replies
    10
    Views
    4,664

    Thanks Barney McGrew for the advice. The program...

    Thanks Barney McGrew for the advice. The program now exits if there is not sufficient memory (though incredibly unlikely) and I have removed sizeof(char) since it is needed. I'm not too worried about...
  16. Replies
    10
    Views
    4,664

    Sorry rags_to_riches, you posted before I...

    Sorry rags_to_riches, you posted before I refreshed. The analyse function does require access to more than one char when more complicated command words are added later. I've managed to sort that out...
  17. Replies
    10
    Views
    4,664

    Thanks std10093, that cleared things up. Those...

    Thanks std10093, that cleared things up. Those pesky pointers, it is always hard to remember the input format especially with char pointers (which sometimes require the addressof operator). Thanks...
  18. Replies
    10
    Views
    4,664

    How do I fix this?

    Thanks for the tip. I wanted to free the memory (when the program ends, just before
    return 0), but it just segfaults - any idea how to resolve this? This is on a Linux-based operating system.
    Code...
  19. Replies
    10
    Views
    4,664

    Anyone able to help a beginner?

    Hi,
    I am a beginner to C, and after learning some stuff thought I'd try and write a simple adventure game. I haven't done much of it yet, only basic interaction, but am wondering how to improve the...
Results 1 to 19 of 19