Hi
In the main I have declared a variable
char string[100];

I need to construct this variable with a function and I have written the code:

char stringReceived(int sockDesc){
char unsigned c;
char tmp[100] = " ";
int i=0;
int n;
  do {
        n = recv(sockDesc, &c, 1, 0); // this function exist for client/server dialog and is not rilevant for my problem
        if (c!='\n'){
           tmp[i]=c;
           i++;}
         } while( c!='\n' );
          tmp[i]='\0';     
return(tmp);
}

In the main I call:
string = stringReceived(nSocketDesc);

When I compile the program, this error is returned:
incompatible types assignement in function stringReceived and the line number is the call.
Sure I mistake the declaration of function, but i don't be able to correct the probleni.
Can someone help me ?
Best Regards
Nick

Don't know what compiler you're using, that's quite a horrible error... but the real problem with that function is it's returning an array of 100 chars, when the function is only set up to return a single char.

Good Luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.