# LabVIEW

cancel
Showing results forÂ
Did you mean:Â

Solved!
Go to solution

## c programe to labview code

Hello,

I am a beginner in labview. Can anyone please help me to convert the C programe code to labview code??

```#include<stdio.h>
int main()
{
int array[]={1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,1,1,1,1,1,1,1,1,1,1,20,0,40,50,1,1,1,1,1,1,1,1,1,1,5,6,7,8,1,2,3,4};
int n = sizeof(array)/sizeof(array[0]);
printf("size of array is :%d \n", n);
int i;
for(i=0;i<n;i++)
{
int j=0;
int count=0;
if(array[i]==1)
{
j=i;
count=1;
while(array[j]==1)
{
j++;
count++;
}
if (count==10)
printf("your  data is at  %d location in array \n",i+count);
}}
return 0;
}
Basically the code is finding a small sequence of data ,say 10 numbers from a large array of data, say 10000 numbers.```
Message 1 of 4
(1,391 Views)
Solution
Accepted by sumeshkp03

## Re: c programe to labview code

I assume you have looked over this: http://www.ni.com/academic/students/learn-labview/

Give it a go and post what you have completed so far so that we can give you specific pointers.

Message 2 of 4
(1,384 Views)
Solution
Accepted by sumeshkp03

## Re: c programe to labview code

Hi sumesh,

Basically the code is finding a small sequence of data ,say 10 numbers from a large array of data, say 10000 numbers.

That's what that code doesâ€¦

- You need a loop to run over your input array.

- You could use ArraySubset to read a subset of required length.

- You can compare this subset with your predefined pattern you are looking for.

- When both are the very same you can output this "pattern at location %d" message

That's a nice job to learn LabVIEW and some of it's very basic features! (Like autoindexing vs. non-indexing loop tunnels, comparison modes of compare functions, array handling and array functionsâ€¦)

Show what you have tried and explain where you have failed!

(We will not do your homework!)

Best regards,
GerdW

using LV2016/2019/2020 on Win8.1/10+cRIO
Message 3 of 4
(1,364 Views)
Solution
Accepted by sumeshkp03

## Re: c programe to labview code

Just to add to the confusion, we goes use Flatten To String on both the data and the search criteria and then use Search/Split String to do the search for us...

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(1,335 Views)