Hi,
The main motivation is that I would like to do a upper shell command on top of the binaries with different number of input files.
e.g ./binary.exe a.txt
./binary.exe b.txt
....where these a.txt and b.txt are input files.
The problem now i am facing is particular only on one input file before even I could move to perform some shell stuffs.
Below are some code snippet which I face error of seg fault i described earlier on.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 20
main (int argc, char *argv[])
{
FILE cfPtr; / for reading data to expand.txt for vector based */
FILE tfPtr; / for reading data from svmkb.txt */
int t[SIZE];
int subs[7];
int label=0;
int i;
char filename[5000];
char dump;
strcpy(filename,argv[2]);
tfPtr = fopen(filename,"r");
if (tfPtr == NULL)
{
printf("Can't find input file %s",filename);
exit(-1);
}
/initialization for statement 1,2 and 4/
for (i=1; i< 5;i++){
subs[i]=0;
}
while(!feof(tfPtr))
{
for (i=0; i<16; i++)
{
fscanf(filename, "%d", t[i]);
fscanf(filename, "%c", dump);
}
while\(t[SIZE-16]>0\)\{
subs[1]=1;
subs[4]=1;
label=0;
t[SIZE-16]--;
\}
}
fclose(tfPtr);
exit(0);
return 0;
}
./test.c a.txt gives me Segmentation Fault(Core Dump)
For your information, my a.txt looks like:-
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ,1,0,1,0
.........
........
....