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
0
votes
1 answer

PHP fclose not freeing up memory

I have a PHP loop whereby I read and process the contents of several files. However, after several…
MattRogowski
  • 726
  • 2
  • 7
  • 22
0
votes
0 answers

Mapping 2d int array to 2d char array (filein to fileout) in C

This is a question from cprimerplus 6th ed. I am trying to open a file containing a 20x30 block of space separated numbers with values between 0-9 and print it in another file with those values corresponding to chars of increasing darkness. Here is…
user4063847
0
votes
0 answers

PHP fclose doesn't unlock the file when fopening it later

My problem appeared when trying to log into a file. I made a cLog class with a ToLog method that works like this: function ToLog($logType, $text) { $myDate = date("H:i:s d/m/Y"); $ip = $_SERVER['REMOTE_ADDR']; $fichero =…
0
votes
1 answer

Append operation on file doesn't seem to be working

I want to append data to files if a certain condition is true, else open a new file and keep writing to that file...this goes on in a loop. This is what I am doing: FILE* ptr firstrun=1 ***some code*** WHILE (condition) { if(!condition1 &&…
fineashell
  • 31
  • 7
0
votes
1 answer

Why isn't file closed immediately in .net?

i am working with a file. this is code: Private Sub WriteXml(ByVal txtName As String) If Not Directory.Exists("GraphXml") Then Directory.CreateDirectory("GraphXml") End If _fileName = "GraphXml\Graph_" & txtName & ".xml" …
donmezburak
  • 159
  • 1
  • 13
0
votes
1 answer

Creating + Writing to a Text file in PHP

As the title said, I am trying to use PHP to write create a text file (eventually a log file) that will be continuously updated with strings. Originally I tried something like this:
0
votes
1 answer

Read a string from text file returning strange characters in MATLAB

I'm reading a string like "1.0.2" from text file with these codes : reader = fopen('Address\My_Text.txt'); Out= textscan(reader,'%str'); Out1=Out{1} ; Out2=Out1{1}; fclose(reader); This code (Out2) returns a string like this: 1.0.2 . This is a…
Eghbal
  • 3,892
  • 13
  • 51
  • 112
0
votes
1 answer

C - Opening differents files using same pointer

I'm trying to retrieve informations by many plain-text files, which will be then stored in a proper struct. To do so, I'm using a function that takes member of the struct to populate and source of the plain-text file where the informations are…
Dan.see
  • 88
  • 11
0
votes
0 answers

MatLab-C MEX File Why fopen() return NULL?

I'm writing this mex file: for (k=0; k
Joseph86
  • 43
  • 1
  • 5
0
votes
2 answers

glibc: fclose() on invalid pointer hangs in pthread_once()

I am seeing some strange behaviour in glibc. The code had a bug where it would pass a random pointer to fclose(). I would have expect it to crash at this point, but instead it hangs in pthread_once(), with the below backtrace. The program does not…
nafmo
  • 448
  • 4
  • 19
0
votes
2 answers

file_put_contents stopped working

I have a PHP code that connects to a FTP server, reads a file's content, makes a minor change, and than overrides the original file. it looks like: $stream_context = stream_context_create(array('ftp' => array('overwrite' => true))); $file_content =…
David Levy
  • 203
  • 2
  • 10
0
votes
2 answers

Filter a CSV file using php

I've got a csv file being delivered via ftp twice a day. I'm trying to write a php file to open this file, filter it by the category column, delete rows which don't have a certain term/terms in then save the file. I've tried lots of variants of…
Danny
  • 43
  • 1
  • 7
0
votes
1 answer

matlab unable to write to text file

I am trying to write to a text file "result.txt" using the following matlab code in ubuntu 13.10 fid = fopen('/home/gaurav/matlab/OCR/result.txt','wt'); fprintf(fid,'asdasd'); fclose(fid) I have changed the permission of file to 777, but nothing is…
user3263192
  • 499
  • 1
  • 4
  • 14
0
votes
0 answers

segmentation fault caused by fclose() while coding multi-threaded ftp protocol in c

I'm having problem of segmentation fault while coding a multithreaded ftp protocol within a Linux environment. This segmentation is due to fclose() file function. This is my code Client code: it tests what ever the client writes as a command. For…
Dhoha
  • 369
  • 3
  • 6
  • 17
0
votes
1 answer

file open and update functions in ci

$result = $this->db->insert('user_reg', $user_data); if($result) { $userid = $this->db->insert_id(); $this->db->where('user_id', $userid); $user_data = $this->db->get('user_reg')->row(); // $userid =…
andy
  • 53
  • 2
  • 11