How to call unmanaged DLL function puts() from C#

1 Answer

0 votes
using System;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [DllImport("msvcrt.dll")]
        public static extern int puts(string c);
        [DllImport("msvcrt.dll")]
        internal static extern int _flushall();

        static void Main(string[] args)
        {
            try
            {
                puts("use puts() function in c#");
                _flushall();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

/*
run:
     
use puts() function in c#
   
*/

 



answered Sep 7, 2015 by avibootz
...