3
I am passing 3 parameters: a vector with the name of 30 cities, one with the x coordinates of the respective cities and the other with the y coordinates.
I need to print on the screen the cities further north, south, etc. I’m still doing tests. I’m trying to assign the city value to the variable char cidade
that I created (it only has 3 indexes because it will be used in the tiebreaker).
However, I’m having a mistake:
"error: incompatible types when assigning to type ľchar[150]' from type ¡char *'" and wondered what the problem is.
void funcao(char cidadeXY[][150], int coordenadasX[], int coordenadasY[])
{
int i;
struct
{
int norte, sul, leste, oeste, centro;
char cidade[150];
}d[30];
for(i = 0; i < 30; i++);
{
d[i].cidade = cidadeXY[i];
printf("%s\n", d[i].cidade);
}
}
As requested, the statements and the function call:
char cidadeXY[30][150];
void funcao(char cidade[][150], int coordenadasX[], int coordenadasY[])
funcao(cidadeXY, coordenadasX, coordenadasY);
The code is big and a lot of it has nothing to do with that function, so I just put the statements and the call.
The signature of the function should be:
void funcao(char** cidadeXY, int coordenadasX[], int coordenadasY[])
. If this settles let me know that I add an official response.– karlphillip
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero