Hi,
I am trying to call a C function, that I wrote to parse a flat file,  into
R. The argument that will go into this function is an input file that I need
to parse and write the desired output in an output file.  I used some hit
and trial approach but i keep on getting the "file not found" or
"segmentation fault" error. I know that the error is in passing the argument
but I could not solve it.

After reading  some of the tutorials, I understood how to do this if the
arguments are integers or floats. I am stuck when i am trying to send the
files. I am attaching stub of each file.
Help appreciated.
Thanks

---------------------------------------
My function call would be:
source("parse.R")
parseGBest('./gbest/inFile.seq',   './gbest/outFile.out');
---------------------------------------
I wrote a wrapper function (parse.R) as follows:

dyn.load("parse.so");
parseGBest = function(inFile, outFile)
{
.C( "parse" , inFile , outFile);
}

How to write receive the filenames in function( , ) above. and how to call
.C

----------------------------------------
parse.c file is as below:  How to receive the argument in funcion and how to
make it compatible with my argv[ ].


void parse( int argc, char *argv[] )  //This is working as standalone C
program. How to receive
                                                  // the above files so that
it become compatible with my argv[ ]
    {

    FILE *fr, *of;
    char line[81];


 if ( *argc == 3 )*/
        {
        if ( ( fr = fopen( argv[0], "r" )) == NULL )
            {
            puts( "Can't open input file.\n" );
            exit( 0 );
            }
        if ( ( of = fopen( argv[1], "w" )) == NULL )
            {
            puts( "Output file not given.\n" );
            }
      }
   else
        {printf("wrong usage: Try Agay!!! correct usage is:=  functionName
inputfileToParse outFileToWriteInto\n");
       }
    while(fgets(line, 81, fr) != NULL)

--
---
--
}



Thanks again
Fahim

-- 
Fahim Mohammad
Bioinforformatics Lab
University of Louisville
Louisville, KY, USA
Ph:  +1-502-409-1167

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to