01-20-2013 11:24 PM - edited 01-20-2013 11:25 PM
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.
01-20-2013 11:46 PM
after combining the numbers, it is better that combined number is array type.
01-21-2013 12:19 AM
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.
01-21-2013 02:30 AM
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.