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...
Type: Posts; User: Joshun
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...
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...
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?
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...
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...
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
...
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...
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...
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...
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...
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...
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++)
{
...
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...
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...
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...
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...
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...
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...
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...