I have written a small client server program using tcp sockets, and i ran into trouble in retrieving the data brought in by the receive function. Like down below.
char *rec;
int buff=1024;
recv(a,rec,buff,0);
You need a char buffer to get the data, but after that i wanted to sort and analyze the data and that was a bit hard to do with a char buffer. It was also hard to covert it to any other format like an array. Finally i came up with something like this.
char *a="Hello World!";
int b=strlen(a);
char *c= new char[b];
c=a;
int x=0;
while(x<b){
cout<<c[x]<<endl;
x++;
It got the job done, but what i wanted to know is, is this the way this is usually done? or is there a better way to do it? if there is what?