1

I am invoking a C/C++ program (exe) from C#, I want to return a float value from my C/C++ to the C# code, I have the exe code which writes file a for a single value, instead I want to return that value to C#. How can I do that?

2 Answers2

3

You could output the result of your C/C++ program to the standard output, and then parse it with C# after the invokation.

Check this answer: Best Way to call external program in c# and parse output

Or if your program is called a lot a time, maybe a better solution would be to let it run and communicate with your C# program through local sockets. C# program may send request by network and get the result back.

Community
  • 1
  • 1
neodelphi
  • 2,706
  • 1
  • 15
  • 22
0

If that code writes a float to a file, then all you can do is read the file afterwards.

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • I cannot afford disk space. This exe needs to run hundreds of times at any give instant. –  Sep 24 '11 at 09:28