How does this effect the system?
Once the program is killed is there still a memory leak?
How do you fix the memory leak once this happened?
Type: Posts; User: socket
How does this effect the system?
Once the program is killed is there still a memory leak?
How do you fix the memory leak once this happened?
Thank you very much.
Please tell me what happens if you do not free(name); ?
I'm simply wanting to take in any argument (string) and allocate enough size to a variable so I can store the input ot a variable.
I don't want to have a set size. (ie: char buf[10];)
Input may be...
For example.
I know I can do the following.
char *name = "myname";
char buf[10];
strcpy(buf,name);
But is my above post doing the same thing?
I am wanting to put argv[1] in my variable name.
#include <stdio.h>
int main(int argc, char **argv)
{
char *name = NULL;
name = argv[1];
printf("Name is %s\n", name);
Okay..
I can read / write / understand any book on C.
When I say any book I mean any "Learn C" sort of book.
My problem now is.. How do I learn more.
The most advanced project I have made was...
I have error checking on strstr and it's not there.
I print out buf before parsing the string and yes PING starts.
PING :blah.blah.blah
That doesn't work either.
I'm really at a lost right now.
They did.
sread = recv(s, buf, sizeof(buf),0); //contents stored in buf
char *p;
p = buf;
while((*p++ = getchar()) != '\n');
*p='\0';
that should work but still doesn't give me anything back from sscanf
Thats the problem I think I'm running into.
It's not null terminated.
How can I add it to the end of the string.
I've tride for looping to the end and then add buf[j] = '\0'; but that doesn't...
if(strstr(buf,"PING"))
{
sscanf(buf,"PING :%s",str);
printf("BOT WILL SEND BACK %s\n",str);
}
the contents of buf is received through a socket....
Basically I'm connecting to a server.
I have the client reading in what the server says.
How can I tell when the server is done sending data?
Here is what I have
...
Example:
I have a string with this "<a href="www.somesite.com">Somesite</a>"
with strstr(str,str1);
I can find where href starts.
Now what C string function can I use to go from the href...
Why doesn't this work?
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *string="This is a long string!";
Works great thank you.
Just out of curiosity is there another way to do this other than using ptrdiff_t?
I have a string with the word scuba in it.
I know how to find it. Well I know how to get a char *c to 's'.
But what I would like to do is search the string for scuba, after finding s with strstr I...
I think I'm a little confused.
Could someone please shed some light on memory allocation.
Basically I would like to create a variable that can hold any amount of bytes.
I do not know how many...
Let's forget the buffer.
Can I just create a 'buffer' that can expand or allocate as needed.
I do not know how large each site will be.
Can't I just create a variable to hold all sizes?
Assuming you read the source code you will see where I do send a message to the server.
I do receive the first 300 bytes or so of the index file. That is all.
Hence why I said is it a buffer...
That does not fix it.
Did not work :(
Anyone else?
still doesn't work.
Just blank space
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
Never mind found it.
I keep getting error
client.c:60: error: syntax error at end of input
unsigned char c;
while(read(sockfd,&c,1) >= 0) putchar(c);