0

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

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by mariocatch
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.