Hi,
i have compile the following code using emcc compiler
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
if(argc > 2 && argc < 2)
{
printf("\nEnter the name of file \n");
return 0;
}
FILE *file = NULL;
// Open file in read mode
printf("file name: %s",argv[1]);
file = fopen(argv[1], "r");
if(file != NULL)
{
printf("\nFile is successfully open\n");
}
else {
printf("\nFile is not opening\n");
return 0;
}
fclose(file);
return 0;
}
i have tried to compile like,
$emcc mycode.c
$node mycode.js input.txt
Output:
file name: input.txt
File is not opening
there is another way to compile and run like,
$emcc mycode.c --preload-file input.txt -o mycode.html
$node mycode.js input.txt
Output:
file name: input.txt
File is successfully open
but at the time of compilation i have to specify the name of file which is opening in read mode,
is there any way to access file from local file system and opening file without giving --preload-file option
thanks in advance
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.