I'm trying to adapt a C ++ function in pure C. I changed the names of the variables and structs
because it is not the case.
typedef struct struct1 {
int a;
int b;
int c;
string d;
} STRUCT1;
typedef struct struct2 {
int aa;
int bb;
int cc;
clock_t time;
} STRUCT2;
vector<STRUCT2> createVector(STRUCT1 str1)
{
vector<STRUCT2> vec;
int var = str1.c, count = 0;
for (int i = 0; i < str1.b; i++) {
usleep(1);
STRUCT2 aux;
aux.aa = 0;
aux.bb = count;
aux.cc = 0;
aux.time = clock();//start times
vec.push_back(aux);
if (--var == 0) {
var = str1.c;
count++;
}
}
return vec;
}
My questions are:
vector<STRUCT2> createVector(STRUCT1 str1)
vector<STRUCT2> vec;
vec.push_back(aux);
How would I pass these 3 lines of code to pure C in the above code?