Originally posted by lcheehan
i tried struct1 = struct2..
but devcpp tell me tat incompatible type assignment...
n it wouldn't let me compile the program...
so y this happen??
how should i solve it plz~~~
It is much easier to help if you post enough relevant information to follow along. For example, you don't mention the types of 'struct1' and 'struct2', and you don't show the offending line of code (this is where the debugging starts). An example of a better post might be as follows.
Code:
#include <stdio.h>
struct sCustomer
{
int sale_no;
char seat_no[32];
};
int main(void)
{
struct sCustomer customer[3] =
{
{ 9999, "zzzzz"},
};
size_t i;
/* display all customers */
for ( i = 0; i < sizeof customer / sizeof *customer; ++i )
{
printf("customer[%d]: sale_no = %d, seat_no = \"%s\"\n",
(int)i, customer[i].sale_no, customer[i].seat_no);
}
/* copy a struct */
customer[2] = customer[0]; /* a line in question */
/* display all customers */
for ( i = 0; i < sizeof customer / sizeof *customer; ++i )
{
printf("customer[%d]: sale_no = %d, seat_no = \"%s\"\n",
(int)i, customer[i].sale_no, customer[i].seat_no);
}
return 0;
}
/* my output
customer[0]: sale_no = 9999, seat_no = "zzzzz"
customer[1]: sale_no = 0, seat_no = ""
customer[2]: sale_no = 0, seat_no = ""
customer[0]: sale_no = 9999, seat_no = "zzzzz"
customer[1]: sale_no = 0, seat_no = ""
customer[2]: sale_no = 9999, seat_no = "zzzzz"
*/
Now I could guess that in your code 'struct1' and 'struct2' have different types, or that you are not attempting to copy structs -- but rather an array member of the struct. But without seeing the code, this would remain purely a guess.