Hi guys!
I have the following code, when I add the text "explorer /start,C:\\Windows\\notepad.exe" to "system()" it works, when I use "char a[5000] ="explorer /start,C:\\Windows\\notepad.exe";" it works, when I read it from the file, add it to the array and pass it to "system()" it does not work.
I have the following code, when I add the text "explorer /start,C:\\Windows\\notepad.exe" to "system()" it works, when I use "char a[5000] ="explorer /start,C:\\Windows\\notepad.exe";" it works, when I read it from the file, add it to the array and pass it to "system()" it does not work.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
char main()
{
char a[500];/*comand text example: system("explorer /start,C:\\Windows\\notepad.exe");*/
unsigned int i=0,z=0; /* Counter. */
char c;/* Chars. */
FILE *ifp; char InputFileName[]="Files.t"; char *InMode="r";/*Files.*/
ifp = fopen(InputFileName, InMode);
if (ifp == NULL)/* This checks the filename for existence/permissions and displays the down message if there is an error with them. */
{
printf("The dialog was canceled by the user, the file doesn't exists or doesn't have the right permissions!");
return -9998;
}
/* Main block. */
for(i=0; (c=fgetc(ifp))!= EOF; i++)/* "fgetc()" has automatic incrementation. */
{
a[i]=c;
printf("%c", a[i]);/* For testing only. */
if(a[i]=='\n')
{
system(a);
a[i+1]='\0';
i=0;
}
/*return fgetc(ifp);*/
}
}