473,412 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Incompatible types in assignment

2
hi everyone,
I am having a trouble in my code. It gives the following error:
Incompatible types in assignment of 'int*' to int[6]

Here is my code:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAXGEN 2
#define MAXPOP 4
#define CHROM_LENGHT 24
#define MUTPROB 0.033
#define CRPROB 0.6
main()
{int oldpop[MAXPOP][24];
int (*ptk)[16][6];
float a;
int i,j,k,l,m,t;
srand(time(0));
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
{a=rand()/(float)RAND_MAX;
if(a<0.5)
oldpop[i][j]=1;
else
oldpop[i][j]=0;
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
{if(oldpop[i][0]==0)
oldpop[i][0]=1;
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
printf("%d %d %d\n",i,j,oldpop[i][j]);
system("pause");
k=0;
for (i=0;i<MAXPOP;i++)
{j=0;
t=0;
while(j<24 && k<6)
{ptk[t][k]=&oldpop[i][j];
k++;
j++;
if(k==6)
{k=0;
t++;}
}
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<6;j++)
printf("%dth %d\n",i,*ptk[i][j]);
system("pause");
return 0;
}

what I am trying to do is to divide the 24 longed oldpop into 4 segments each of which is 6 longed.

thanks for your interest.
Jan 25 '07 #1
1 1868
willakawill
1,646 1GB
Hi. This might work better for you
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<time.h>
  4. #define MAXGEN 2
  5. #define MAXPOP 4
  6. #define CHROM_LENGHT 24
  7. #define MUTPROB 0.033
  8. #define CRPROB 0.6
  9. main()
  10. {
  11.     int oldpop[MAXPOP][24];
  12.     int (ptk)[16][6];
  13.     float a;
  14.     int i,j,k,l,m,t;
  15.  
  16.     srand(time(0));
  17.     for (i=0;i<MAXPOP;i++)
  18.         for (j=0;j<24;j++)
  19.         {
  20.             a=rand()/(float)RAND_MAX;
  21.             if(a<0.5)
  22.                 oldpop[i][j]=1;
  23.             else
  24.                 oldpop[i][j]=0;
  25.         }
  26.     for (i=0;i<MAXPOP;i++)
  27.         for (j=0;j<24;j++)
  28.         {
  29.             if(oldpop[i][0]==0)
  30.                 oldpop[i][0]=1;
  31.         } 
  32.     for (i=0;i<MAXPOP;i++)
  33.         for (j=0;j<24;j++)
  34.             printf("%d %d %d\n",i,j,oldpop[i][j]);
  35.  
  36.     system("pause");
  37.     k=0;
  38.     for (i=0;i<MAXPOP;i++)
  39.     {
  40.         j=0;
  41.         t=0;
  42.         while(j<24 && k<6)
  43.         {
  44.             ptk[t][k] = oldpop[i][j];
  45.             k++;
  46.             j++;
  47.             if(k==6)
  48.             {
  49.                 k=0;
  50.                 t++;
  51.             }
  52.         }
  53.     }
  54.     for (i=0;i<MAXPOP;i++)
  55.         for (j=0;j<6;j++)
  56.             printf("%dth %d\n",i,ptk[i][j]);
  57.     system("pause");
  58.     return 0;
  59. }
Jan 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Brian Stubblefield | last post by:
Dear clc members, I am new to C and am posting several messages concerning a large C program that I am debugging. I am encountering a "incompatible types in assignment" warning for the...
2
by: Dennis Schulz | last post by:
Hi all, the following programm is supposed to check for login and password with inbuilt linux functions. in line 57 and 64 there are erorrs: incompatible types in asignment. whats wrong with...
10
by: gk245 | last post by:
I have something like this: #include <stdio.h> main () { struct line { char write; char read;
8
by: fei.liu | last post by:
I have the following source code. It seems wierd to me why gca's value cannot be reassigned. It's afterall a pointer and has a pointer value. I am aware that the standard says it's not allowed. But...
13
by: william | last post by:
code segment: long int * size; char entry; ............. size=&entry; ************************************* Gcc reported 'assignment of incompatible pointer type'.
1
by: pyo2004 | last post by:
Here's the definition of work_struct struct work_struct { unsigned long pending; struct list_head entry; void (*func)(void *); void *data; void *wq_data; struct timer_list timer; };
6
by: billiabon | last post by:
Hello,everybody! I need your help! My problem is this assignment char pnm; void enqueue(int pd,char pnm,int pnum,int ptm,struct queue *z) {struct node *p; p=(struct node...
4
by: pandaemonium | last post by:
I have two quick problems with the code I am writing: First, I define a struct of char arrays (strings) and then try accessing the same. I get an "incompatible types in assignment" error: struct...
2
by: kardon33 | last post by:
I am getting a "error: incompatible types in assignment" error and cant figure out why? I am trying to set lastRow to row at the end of the code snippet. int row; int lastRow; size_t...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.