Hi,
Here is an example for your case:
Prior to calling the import file functions, you need to first programmatically load and compile FileImport.c. This can be done from script using the command: 
run.LoadOC(Originlab\FileImport.c, 16);
// Option 16 ensures that all dependent Origin C files are loaded,
// by scanning for the corresponding .h in FileImport.c
#include <..\originlab\fu_utils.h>
 
void ImportASCII_Ex3()
{
	//string fileName = GetOpenBox("*.txt");  // txt file browser
	//printf("The file chosen is %s\n.", fileName);
	string fileName = "E:\\file.txt";
	if( !fileName.IsFile())
		return;
 
	// create a new worksheet
	Worksheet wks;
	wks.Create();
 
	// ascii import
	ASCIMP ai;
	initASCIMP(ai);  // initialize
	ai.iAutoSubHeaderLines = 0;  // disable auto detect headers
	ai.iSubHeaderLines = 5; // set number of header lines to be 5
	ai.nLongNames = ai.iHeaderLines; // Set first header line as Long Name
	ai.nUnits = ai.iHeaderLines + 1;  // Set second header line as Units
	ai.nFirstUserParams = ai.iHeaderLines + 2; // Set header lines 3 to 5 as user parameters
    ai.nNumUserParams = 3; // Set the number of user params
	
	ai.iDelimited = 1;  // use delimiter
	ai.iDelimiter = ASCIMP_DELIM_COMMA;  // comma as delimiter
	int nret = AscImpReadFileStruct(fileName, &ai, AIRF_USE_ASCIMP);
	if(0 == nret )
	{
		// import
		wks.ImportASCII(fileName, ai);
	}	
}
Regards!
Sean