LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Covert numbers in array to one number

 

Good afternoon.

I have one question in CVI.

 

In the current stage, I collect the 30 data in one second at array

For example, there is one array d[30] and it consists of d[0] = 101, d[1]=1, d[2]=3 ... d[29]=1; 

 

I want to combine these numbers in array 'd' as one variable like 10113...1;

I know "strcat" function but it is for string right?

Thus, I want to know how I solve it. 

Please give me a idea. Thanks.

0 Kudos
Message 1 of 4
(2,617 Views)

 

after combining the numbers, it is better that combined number is array type. 

 

0 Kudos
Message 2 of 4
(2,613 Views)

int CVICALLBACK TIMER (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
HRESULT error = 0;
int C;
double rand_data[20];
int event_num[5][50];
int i,k;
char buf[100];
char buf1[40];
char buf2[40];
char buf3[40];

switch (event)
{
case EVENT_TIMER_TICK:


for (i=1;i<11;i++)
{
k=3*(i-1);

rand_data[i]=(double)Random(normal_state[i][1],normal_state[i][2]);
event_num[1][k]=101;
event_num[1][k+1]=i;
SetTableCellVal(panelHandle, PANEL_TABLE,MakePoint(i,1),rand_data[i]);

if(rand_data[i]<range_value[i][1])
{
event_num[1][k+2]=1;
}
else if(rand_data[i]>range_value[i][2])
{
event_num[1][k+2]=2;
}
else
{
event_num[1][k]=0;
event_num[1][k+1]=0;
event_num[1][k+2]=0;
}

sprintf(buf1, "%d\0", event_num[1][k]);
sprintf(buf2, "%d\0", event_num[1][k+1]);
sprintf(buf3, "%d\0", event_num[1][k+2]);

strcat(buf, buf1);
strcat(buf, buf2);
strcat(buf, buf3);

}

printf("%s", buf);
printf("\n");

}
return 0;
}

 

 

This is my code now.

This code shows acculumated buf. I just want to show one buf in one turns of timer.

In addition, it shows some strange characters.

How can I solve it TT help me. 

0 Kudos
Message 3 of 4
(2,604 Views)

It's not clear to me whether you want as output a single number or an array...

Nevertheless, the output number can be a 51-digit one, far beyond the capacity of integers and int64 types!

Maybe you should rethink your algorithm or at least explain better what you are aiming to.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(2,596 Views)