N
nagrik
Hello group,
I am reading an 'mpeg file' from the socket. In read socket I specify
a 'char* buffer' to read the file. However, the content of actual data
contain '\0' characters at various places.
When I read the full content I copy the char* buffer into a string type
variable. The code looks
like
int len;
char * buf[256];
int size = 256;
string content;
len = read(sockFd, buf, size);
content = buf;
Here if I print buf anything after the '\0' is not printed.
When I copy the buf to content anything after '\0' wipes out and is not
copied. I want full
buffer to be copied to content and later on down the line I want to
save it to a file including
any '\0' characters.
I also want to print the full buffer on the stdout including anything
after '\0' character.
Folks! any suggestion. This bug is stopping my program to proceed.
Thx.
arun
I am reading an 'mpeg file' from the socket. In read socket I specify
a 'char* buffer' to read the file. However, the content of actual data
contain '\0' characters at various places.
When I read the full content I copy the char* buffer into a string type
variable. The code looks
like
int len;
char * buf[256];
int size = 256;
string content;
len = read(sockFd, buf, size);
content = buf;
Here if I print buf anything after the '\0' is not printed.
When I copy the buf to content anything after '\0' wipes out and is not
copied. I want full
buffer to be copied to content and later on down the line I want to
save it to a file including
any '\0' characters.
I also want to print the full buffer on the stdout including anything
after '\0' character.
Folks! any suggestion. This bug is stopping my program to proceed.
Thx.
arun