Friday 15 February 2013

c - can't open file, file descriptor returns -1 value -


When I run this program. The file descriptor returns -1 value and therefore the program ends. I do not know why this is happening, like the PED value is actually the name of the file that I want to open.

  const char * psyn = "product / product ID:"; Four lines [100]; PFile = fopen ("pids.txt", "r"); If (pFile == NULL) perror ("Error opening file"); Other {while (fgets (line, size (line), pfile)) {if (strstr (line, pin) == line) {leng = strlen (line); If (line [leng-1] == '\ n') row [leng-1] = 0; If (line [0] == '\ n') line [0] = 0; Pid = line + strlen (psyn) +1; Strcat (PID, T); Leg = Stellen (PID); If (pid [leng-1] == '\ n') pid [leng-1] = 0; FD = Open (PID, O_RDWR, 0644); If (FD == -1) COAT & lt; & Lt; "Air In File \ n"; Other {//. Rest of the program}    

 Pid = line + strlen (psyn) +1;  My suspicions awakened the first strlen (here) is not efficient here Second, 1 string is a long one.   

No comments:

Post a Comment