-2

I am calling a dll in labview where the dll gets two numbers for summing and then has to be saved in txt file. Summing works perfectly fine, but writing it in the txt, doesn't work. When I a create separate c project and saving some random number in the txt with the same code then it works. Where is the trick?

Dll:

#include<stdio.h>
FILE *ptr_file;
int __declspec(dllexport) ArrayFind(int a, int b, int* c);

int __declspec(dllexport) ArrayFind(int a, int b, int* c)
{
    *c = a + b;
    ptr_file = fopen("C:\\FILE.txt", "w");
    fprintf(ptr_file, "%d\n", c);
    fclose(ptr_file);

    return;
}
user4520
  • 3,401
  • 1
  • 27
  • 50
Josuhua
  • 1
  • 3
  • Why are you declaring `ArrayFind` to return `int` when in fact you don't return anything? – user4520 May 21 '15 at 15:56
  • I modify the code several times and forget to change the name, It should be sum or something else. Also I want to return a int, because then I know that the dll has been executed and also in the code should be "return 1". Sorry for my sloppiness. – Josuhua May 21 '15 at 17:00

1 Answers1

0

Why do you need to use a DLL to get the numbers?

LabVIEW can easily read values from various hardware, perform the summing and write to a file all using it's native functions.

Are you trying to generally learn how to call a DLL from LabVIEW?

Phil Brooks
  • 643
  • 4
  • 8