Results 1 to 4 of 4

Thread: Error: Incompatible types in assignment

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Error: Incompatible types in assignment

    I am using C language, I have a small problem, it gives me the following error message: "incompatible types in assignment"
    Code:
    char * address (int octet1, int octet2,int octet3)
    {
    char *ad [64]
    if octet 1> =1 && (octet 1<=26))
    {
    ad = strcat (octet1. "0.0.0.");
    else if (octet 1<=128) && (octet 1<=192)&& (octet 1<=255)
    {
    ad = strcat (octet1, octet2 "0.0.0.");
    }
    return *ad;

    The function is supposed to send me the address network (concatenated with the bytes passed as parameters ...) or it does not work very well ...Thank you in advance for your help!

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Error: Incompatible types in assignment

    Malloc allocates memory and returns a pointer to the beginning of that block of memory. The malloc (memory allocation) is used to dynamically allocate memory at run time. Possible uses for this function are: Read records of an unknown length.
    Read an unknown number of database records.The malloc() function shall allocate unused space for an object whose size in bytes is specified by size and whose value is unspecified.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Error: Incompatible types in assignment

    You can pass to the function strcat more than two parameters. But I remind you of the prototype of the function strcat:
    char * strcat (char * string1, const char * string2);
    Even if the problem is not there, it is also possible that the compiler rattle as you pass it in the int parameters, or it expects pointers to char.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Error: Incompatible types in assignment

    strcat is not used like that ...
    It only take 2 and 2 char pointers as parameters. The strcat() function will concatenate two strings by placing the second input on the end of the first.
    You need to convert the int to char * (using sprintf for example), then concatenate example Byte1 with Byte2, retrieve the string in the ad, and then concatenate with ad octet3, etc. ...

    You make a confusion by declaring ad. To declare a string is
    char d [64] = "";
    or
    char * d = malloc (64 * sizeof (* ad));

Similar Threads

  1. Replies: 4
    Last Post: 15-01-2012, 09:00 PM
  2. Get incompatible browser error while opening Facebook
    By RAJalias in forum Technology & Internet
    Replies: 5
    Last Post: 14-11-2011, 01:48 PM
  3. VBA: Adding assignment to the task
    By kyosang in forum Microsoft Project
    Replies: 4
    Last Post: 26-03-2011, 01:21 AM
  4. HP J4680 Incompatible Ink Cartridge error message
    By Lyandon in forum Portable Devices
    Replies: 5
    Last Post: 04-09-2010, 04:10 AM
  5. Exporting assignment information to Excel
    By Jhal in forum Microsoft Project
    Replies: 7
    Last Post: 06-01-2010, 08:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,251,311.89435 seconds with 17 queries