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 Unable to do file operations file (fopen, fwrite, fclose)

I am facing an issue. This is what my script looks like: $file = fopen("logs/log.php", "r+") or die("Kan bestand (1) niet openen bradda!"); $content = fread($file, filesize("logs/log.php")); fclose($file); $filee = fopen("logs/log.php", "r+") or…
ndev
  • 1
0
votes
1 answer

How to redirects to the sandbox use "printf" in iOS?

In iOS development, I would like to test the output of the log to the local file. Use the redirection can be done to "NSLog" output to the file, but if I use the "printf" output when the use freopen([logFilePath…
David
  • 1
  • 2
0
votes
4 answers

Impossible to close a file after reading it - C programming

I have written a function which reads a file full of text, and proceeds to concatenate all the lines into a single string. It works, but the fclose() instruction, when used, launches an error : "* Error in `./main': double free or corruption (out):…
Micawber
  • 707
  • 1
  • 5
  • 19
0
votes
1 answer

How do I call a function to close a file using FILE *fp

In main I create a file pointer, pass that to a function to open it and I want to have a separate function to close the file but I am not able to close the file. What am I missing? I do not get an error but the way that I am checking indicates the…
dmaelect
  • 151
  • 2
  • 14
0
votes
0 answers

fclose not work after while (!feof($csvfile)) loop

This code works properly but fclose() does not run in the end. Can anyone spot the issue with my code?
0
votes
0 answers

Close form when on time fixed C#

I have a trouble with my form. When my fo already open in a short time. I would like the form will auto close on time i fixed Example: i opened that form at 7h40 and form will auto close at 8h10 every day. I am using timer_tick but it is not working
0
votes
2 answers

fclose() expects parameter 1 to be resource

I've a problem with a PHP script that creates some csv file. The PHP script is the following:
luca
  • 55
  • 2
  • 8
0
votes
0 answers

FILE pf lost its value

Program and file created as I wished. But when program about to end (void main() {...return 0;}) I get an error. When I check for pFile value on main function its like it never exist. Please Help. Thank a head! :) FILE *pFile; char name[SIZE]; int…
0
votes
3 answers

Merging a list of files into another

I'm trying to make a program that takes a series of files and copies them into another one. for example ./foobar arch1.txt arch2.txt arch3.txt must create arch3.txt with the contents of arch1.txt arch2.txt, archN.txt. This is my code: #include…
Telefang
  • 133
  • 1
  • 15
0
votes
2 answers

fclose crashes when closing my recent created file

I'm trying to create a log file for each program execution. char * createLogFile(char *filename) { char path[100] = "logs_folder/"; char text[100] = ""; strcpy(text, filename); strcat(path, text); strcat(path, ".txt"); FILE *logFile; …
user2326369
0
votes
1 answer

Closing opened files

This code works but I want to close opened files. How to change this code ? with open(output_file, "w", newline='') as f_output: try: os.remove(output_file) # Delete old file …
Luk
  • 185
  • 1
  • 2
  • 10
0
votes
2 answers

fgets only read the first line of file

I am trying to read a file from my .cpp file. I am using C libraries, so do not confuse on that. So the problem is as clear as what I said in the title. fgets method can read the first line but when it comes to the second line, it cannot read…
Kutay Demireren
  • 640
  • 1
  • 10
  • 25
0
votes
0 answers

fopen() and fprintf() function well but the file is empty-

I have a problem like this one: fprintf function not working but it returns positive number I create the file in main.c with fopen("name","w"); and write to it in sec.c with fopen("name","a") and fprintf;. but I use fclose() & fopen(), each time…
LiorA
  • 53
  • 1
  • 12
0
votes
1 answer

Valgrind detects memory leak at fclose()

Why does valgrind say I've got memory leak at the fclose() call? #include class Stream { public: Stream(); ~Stream(); private: char* pszOutput; size_t size; FILE*…
JimmyY
  • 11
  • 3
0
votes
0 answers

PHP - can't unzip a uploaded file

I'm running 2 simple function:
Angelo
  • 1
  • 2