# Thread: Function returning a structure - "no suitable constructor exists"

1. ## Function returning a structure - "no suitable constructor exists"

Hi guys,
it is my first post here (and first problem) and im just starting my journey with C programming, so please be kind to me

Here is my problem:
I am trying to have my function "Krzywa" returning a structure with array, but i get this "vect" at the end of function highlited with an error "no suitable constructor exists to convert from vector[4] to Vector".
Code:
```#include <stdio.h>
#include <math.h>

float siec [10][10];
float previous [10][10];
FILE *fp ;
float fs;
float u, t, x, theta; //predkosc, krok czasowy, dlugosc komorki, kat miedzy czyms a osia glowna
float mi, Tmi, Tk; //
float gamma, Teq, K, L; // cos, temp frontu, krzywizna, cieplo fazowe?
float mi0, deltami, ms, dt; //mio, stale
float siec [10][10];
float previous [10][10];

float dfsx, dfsy, n0x, n1x, n2x, n3x, n0y, n1y, n2y, n3y;
float dolnaGranica, gornaGranica;
struct Vector
{
int x;
int y;
};
struct Vector vectors[4];

void zerowanie ()
{
int i, k;
for (i=0; i<10; ++i){
for (k=0; k<10; ++k){
siec[i][k]=0;
}
}
for (i=0; i<10; ++i){
for (k=0; k<10; ++k){
previous[i][k]=0;
}
}
}

struct Vector Krzywa (int i, int k)
{
int n;
struct Vector vect[4];
for (n=0;n<4;n++){//jak znajduje faze stala w sasiedztwie, tworze krzywa K
switch (n){
case 0://1 wierzcholek
dfsx=-previous[i][k-1]-previous[i+1][k-1]+previous[i][k]+previous[i+1][k];
dfsy=-previous[i+1][k-1]-previous[i+1][k]+previous[i][k-1]+previous[i][k];
vect[0].x = -dfsx/(sqrt(dfsx*dfsx+dfsx*dfsx));
vect[0].y = -dfsy/(sqrt(dfsx*dfsx+dfsx*dfsx));
//printf("%d %d",vectors[0].x,vectors[0].y);
break;
case 1:    //2 wierzcholek
dfsx=-previous[i-1][k-1]-previous[i][k-1]+previous[i-1][k]+previous[i][k];
dfsy=previous[i-1][k-1]+previous[i-1][k]-previous[i][k-1]-previous[i][k];
if (dfsx==0 && dfsy==0)
{
vect[1].x =0;
vect[1].y =0;
}
else {
vect[1].x = -dfsx/(sqrt(dfsx*dfsx+dfsx*dfsx));
vect[1].y = -dfsy/(sqrt(dfsx*dfsx+dfsx*dfsx));
break;
}
case 2:    //3 wierzcholek
dfsx=previous[i-1][k+1]+previous[i][k+1]-previous[i-1][k]-previous[i][k];
dfsy=previous[i-1][k]+previous[i-1][k+1]-previous[i][k+1]-previous[i][k];
if (dfsx==0 && dfsy==0)
{
vect[2].x =0;
vect[2].y =0;
}
else {
vect[2].x =-dfsx/(sqrt(dfsx*dfsx+dfsx*dfsx));
vect[2].y =-dfsy/(sqrt(dfsx*dfsx+dfsx*dfsx));
break;
}
case 3:        //4 wierzcholek
dfsx=previous[i][k+1]+previous[i+1][k+1]-previous[i][k]-previous[i+1][k];
dfsy=-previous[i+1][k]-previous[i+1][k+1]+previous[i][k+1]+previous[i][k];
vect[3].x = -dfsx/(sqrt(dfsx*dfsx+dfsx*dfsx));
vect[3].y = -dfsy/(sqrt(dfsx*dfsx+dfsx*dfsx));
break;
}
}
return vect;
}```
Any idea what it can mean? I omit the rest of the code with main function as the problem lays somewhere in here.

2. What is the exact error message? It should have a line number that can help in discovering the source of the error.

Furthermore, are you compiling as C or C++?

`Error	9	error C2440: 'return' : cannot convert from 'Vector [4]' to 'Vector'`