Recent content by James889
-
Getpwnam no such file or directory
There seems to be a similar situation with the hashed password found in master.password and the hash generated by crypt(), they are different, despite hashing being done on the same clear text password. In this case there are no trailing newlines.- James889
- Post #5
- Forum: Programming and Computer Science
-
Getpwnam no such file or directory
Duh, silly newbie mistake :)- James889
- Post #3
- Forum: Programming and Computer Science
-
Getpwnam no such file or directory
Hi, I'm trying to write a simple authentication plugin which authenticates a user against /etc/master.passwd. The problem is the call to getpwnam() which fails with 'no such file or directory' Relevant code below char username[10]; memset(username,0,sizeof(username)); /* Read the username */...- James889
- Thread
- File
- Replies: 4
- Forum: Programming and Computer Science
-
What are the issues with this code for reversing a string in memory?
Ok, so after a bit of fiddling i finally managed to come up with a version that works(not saying anything about code quality etc ;) ) char *reverse(char *buf){ /* Allocate enough memory for the string */ int length = strlen(buf); char *ptr = calloc(length,sizeof(char)); char **p2p...- James889
- Post #16
- Forum: Programming and Computer Science
-
What are the issues with this code for reversing a string in memory?
void reverse(char *buf){ unsigned int strlen = 0; /* Allocate memory for the reversed string */ char *ptr; ptr = (char *)malloc(100); /* Find the length of the string in the buffer */ while( *buf++ != '\0'){ strlen++; } /* Copy */ for(strlen;strlen>0;strlen--){ *ptr++ = *buf--...- James889
- Post #11
- Forum: Programming and Computer Science
-
What are the issues with this code for reversing a string in memory?
So why do i get different results from *buf and **bufptr ?- James889
- Post #7
- Forum: Programming and Computer Science
-
What are the issues with this code for reversing a string in memory?
One thing i don't understand. The statement 'char **bufptr = buf' and putchar(bufptr) whould print out the same output as putchar(buf). But it doesn't. Why? char *reverse(char *buf){ /* Allocate memory for the reversed string */ char *ptr = (char *)malloc(100); char...- James889
- Post #5
- Forum: Programming and Computer Science
-
What are the issues with this code for reversing a string in memory?
Hi, I'm trying to write a simple program for reversing a string stored in memory. This is what I've come up with. For some reason this code coredumps, so something is wrong. any ideas ? #include <stdio.h> #include <string.h> #include <stdlib.h> char *reverse(char *buf,unsigned...- James889
- Thread
- Memory Reverse String
- Replies: 16
- Forum: Programming and Computer Science
-
How Can I Add Support for Multiple Client Connections to my TCP Server?
Hi, I have a simple tcp server, to which i would like to add support for multiple client connections via pthreads. This is what i had in mind, calling accept in a separate thread. I this similar to what you would do? . . . int sock = socket(PF_INET,SOCK_STREAM,0); int...- James889
- Thread
- Multiple
- Replies: 1
- Forum: Programming and Computer Science
-
What Does This Regular Expression Mean?
Is this the same as saying 'match as much as possible up until a white space is found' ?- James889
- Post #3
- Forum: Programming and Computer Science
-
What Does This Regular Expression Mean?
Howdy, I came across a regular expression i couldn't get my head around. ' there \([^ ]*\)' echo "Howdy there neighbor" | sed 's/there \([^ ]*\)//' returns howdy. It's the subgroup that's a bit confusing. match any sentence which contains banana then a space and then a non-space character...- James889
- Thread
- Expressions Reading Regular
- Replies: 4
- Forum: Programming and Computer Science
-
Designing a Scalable C Chat Server
Ouch, sounds difficult.- James889
- Post #3
- Forum: Programming and Computer Science
-
Designing a Scalable C Chat Server
Hi, I developed a simple ad-hoc client/server chat program, however the design isn't exactly scalable since the addresses are hard coded and one of the clients is also the server. So i wanted to write a dedicated server, to which multiple clients could connect and chat, like irssi.. how...- James889
- Thread
- Approach Chat Server
- Replies: 3
- Forum: Programming and Computer Science
-
C - Print connecting clients address
Hi, I'm currently trying to implement a simple client server program in C. Needless to say i ran into troubles, and being a novice, i turned here for some advice. I have a function to print the connecting peers address. I don't even know if this is the right way of doing it. For...- James889
- Thread
- Replies: 4
- Forum: Programming and Computer Science
-
Calculating Interest with Recursive Function
That's why these small exercises are so useful, you always learn something.- James889
- Post #8
- Forum: Programming and Computer Science