Can i use systemverilog task or function to be called in main() in c program

In reply to waleedOsama:

In your c program include svdpi.h header file.Prefix the extern keyword in front of all methods being exported to C.

funcs.c should look like:
include <stdio.h>
include “svdpi.h”
extern int sayHello();
void something() {
printf(“something\n”);
sayHello();
}

You have to use the below format in sv file----

export “DPI” function write; // Note – not a function prototype
// This SystemVerilog function could be called from C
function void write(int address, int data);
// Call C function
slave_write(address, data); // Arguments passed by copy
endfunction

Now you can use the sv task in your c program.
Example:

module data_ex2 ();
export "DPI-C" function Double;
import "DPI-C" context task doit(input int val);

function void Double(input int num_in, output int num_out);
  num_out = 2 * num_in;

endfunction

initial
begin
  doit(2);
  doit(5);
end
endmodule