Questions tagged [fclose]

fclose closes an open file resource, releasing it from memory and any write-locks on the file.

fclose closes an open file resource, releasing it from memory and any write-locks on the file.

It is a matching function for fopen, after read and writes have been completed. This function will release any write-locks on the file. While often unimportant for batch processes (when a process ends, write-locks are automatically released), it becomes important to release unused resources for long-running applications or background processes.

278 questions
-1
votes
1 answer

fwrite() expects parameter 1 to be resource and fclose() expects parameter 1 to be resource

private function WriteFile($file,$mode,$content){ $handle = fopen($file, $mode); fwrite($handle, $content); fclose($handle); } this is my code and giving me the error fclose() expects parameter 1 to be resource, boolean given in and …
-1
votes
2 answers

Solving Error in `./recover': free(): invalid next size (normal): 0x0000000001ddd270 *** Aborted in c

Code must read 512 bytes at a time from a file that has raw JPEGs in order to retrieve them. When a JPEG is found, all the following blocks of 512 bytes are stored in a a file until a new JPEG is found, once a new JPEG is found, the file img is…
-1
votes
1 answer

C program doesn't save to file in while loop

I wrote o program which have to work in inf while loop. In the loop, program have to save some datas to file and close this file. In the loop there is a sleep function which sleep program for 10 seconds. Then I want to check what is in the file but…
kmbm
  • 115
  • 2
  • 9
-1
votes
1 answer

php delete file with unlink()

I have read a lot of pages about this but I just can't get it to work. I have a file on my server that needs to be deleted after the file has been imported. The file is a .csv file and opened with fopen. After import the file is closed with…
Interactive
  • 1,474
  • 5
  • 25
  • 57
-1
votes
1 answer

Add /clear command to html form

I have some code for a type of note making thing:

Notes About the rebellion:

Subject:

Note:

Terry Anderson
  • 89
  • 2
  • 10
-1
votes
3 answers

Adding a line break to php Fwrite output

Basically, I was trying to find a simple piece of code for a simple note taking thing in html, I want to type in an html input form, then that input be added on to a text file i found this,

Adding a text block to a text file:

Terry Anderson
  • 89
  • 2
  • 10
-2
votes
3 answers

Strange behavior using fclose

When testing the fclose function, the printf("File \"file2.bin\" inexistent!"); line is not reached. If the fclose(p_file2) line is removed, the message is shown. #include int main() { printf("Hello files"); FILE *p_file1,…
Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
-2
votes
1 answer

How to read an ascii stl file to print it to a file?

How to read an ASCII STL file cubea.stl to print it to a file output.dat? I wrote a part of the program, but this main.cpp doesn't work. I'm probably missing some programs in main.cpp. main.cpp #include #include #include…
-2
votes
3 answers

php write successful logins and unsuccessful to text file

I've been trying to write my successful logins/failed logins to a txt file but it doesn't work. if($_POST['username']==$username && $_POST['password']==$password){ $_SESSION['username']=$username; header('location:mainpage.php'); …
-2
votes
2 answers

Php fwrite/fclose warning

I have the following code fragment which works btw: $txt = ""; $slot = file_put_contents('../offer/slots.php', $txt.PHP_EOL , FILE_APPEND); fwrite($slot, $txt); fclose($slot); $theCounterFile…
Ivan
  • 1,274
  • 16
  • 22
-2
votes
1 answer

calling fclose on a memstream FILE causes segmentation fualt

I have an interface that only prints strings to a file and Im working on a embedded system so opening a file is not an option I created a virtual file in a memory using open_memstream , and after using the file and parsing the string the program…
Alireza Soori
  • 645
  • 9
  • 25
-2
votes
2 answers

Why would C automatically process the next available pointer if the designated pointer is closed?

I have a question about FILE pointer operations in C; specifically, what happens when a command uses a closed file pointer. Here is an example FILE *fp1; fp1 = fopen(file1,"r"); function1(fp1); fclose(fp1); FILE *fp2; fp2 =…
CrazyFrog
  • 323
  • 5
  • 19
-2
votes
1 answer

saving and transfering data from one text file to another

Having problems with transferring a data from one text file to another. My idea is to transfer it per character but it seems to not be working. I have added these codes at the beginning FILE *addressPtr; FILE *ressPtr; and addressPtr =…
-2
votes
3 answers

Fclose causing seg fault in C

I keep getting a seg fault if and only if I attempt to close a file: FILE *outFilePtr = fopen(*(argv + 2), "w"); //open file, yes i'm sure it opens fclose(outFilePtr); //sometime later in the program. The program runs from start to finish…
SystemFun
  • 1,062
  • 4
  • 11
  • 21
1 2 3
18
19