Questions tagged [fopen]

fopen opens a file resource, in order to read, write or append content to it.

fopen opens a file resource, in order to read, write or append content to it. It originated in the C standard library, but has been ported to other languages (and sometimes renamed simply to open).

In the C standard library, fopen resides in stdio.h, with the signature FILE *fopen(const char *path, const char *mode);.

For example:

FILE *file_pointer = fopen("filename","r");

Generally, there are 3 modes:

  • r, which opens a file for reading
  • w, which opens a file for writing (clearing it in the process)
  • a, which opens a file for appending to the end
  • There are also a selection of "hybrid" modes (r+, w+, a+) whose names vary by language

To close an open file, see fclose.

2898 questions
0
votes
3 answers

Very quick example to get me started with fopen / curl request

I am looking to start pulling data from comindwork, but I have never used any web services before so I don't really know how to get started. Someone has suggested I can pull back data with either fopen or send a curl request, but I don't know which…
wills
  • 1
0
votes
1 answer

Inexplicable "Invalid Argument" error from fopen_s

In essence I have come across an issue while working on a project to send files over a socket. I'm a bit of a newbie, and after a few hours of searching I still haven't found a working solution, but I have boiled down the problem into the following…
Mr_IO
  • 43
  • 5
0
votes
1 answer

fopen() returns NULL but open() syscall returns proper file descriptor?

I've been trying to run this very simple C code on Ubuntu 20.04LTS #include #include int main() { FILE *f; f=fopen("tree.txt","r"); if(f==NULL){ perror("fopen"); exit(1); } …
Mor010101
  • 9
  • 2
0
votes
0 answers

Impact of file socket descriptor closed twice bug in multithreaded program

fd = open("file", O_RDONLY); if (fd < 0) exit(1); while((res = read(fd, buf, sizeof(buf)))){ if (res < 0){ close(fd); fprintf(stderr, "Read error!\n"); break; } else { printf("Read %zd bytes\n", res); } } close (fd); In the single-threaded program…
dk chouhan
  • 11
  • 1
0
votes
1 answer

Why do I get the error, XML_IO_FLUSH, with xmlDocDump

With modes "w", "w+" and "w+b", I get XML_IO_FLUSH. With the file open, I can successfully call fputs() and fclose() with proper, expected results. BTW: I work around the problem using xmlDocDumpFormatMemory() and handling the file IO separate from…
Danny Holstein
  • 144
  • 1
  • 14
0
votes
0 answers

Php FOPEN - CENTOS 7 - Cant Create File or Folder

EDIT 01 UPDATE: ERROR Showing UP Warning: mkdir(): Permission denied in /var/www/html/projeto01/index.php on line 7 Sucess. Dir Created EDIT 02 Change to FEDORA and is working. Thank you guys before submitting this topic I read and tried all the…
0
votes
1 answer

mcrypt CBC unable to access outside www

From a novice: In currently experimenting with mcrypt CBC. I have no issues getting recall.mcrypt.php to recall mcrypt.php file inside the same directory but because of best practices and security needs, I'm placing mcrypt.php outside the directory…
crash_course
  • 127
  • 2
  • 12
0
votes
1 answer

Problem with fopen error using getopt optarg

Running it does not open the file that i'm parsing with optarg in option -w. I run with ./programname -w filename.txt filename.txt is in the same directory with exe file etc... I post here a part of code to let you understand, thank you! P.S. Sorry…
ClaudioDeLise
  • 247
  • 1
  • 9
0
votes
0 answers

Tizen studio gear s3 smartwatch saving text file

I am using Tizen Studio to create a native smartwatch app for a Samsung Gear S3. I want to record accelerometer data and store it in a csv text file, however I can't seem to access any files. If I use app_get_data_path(), it returns a path to the…
0
votes
2 answers

Warning: Use of undefined constant fp - assumed 'fp' - PHP Version 7.2.34

I have problem witth this warning: Warning: Use of undefined constant fp - assumed 'fp' My code is: No orders…
0
votes
1 answer

fopen function is not creating the file .txt

I'm using Dev C++ as IDE, windows 10 and this is the code #include main(){ FILE *f; f=fopen("C:\\Users\\min2\\Documents\\asd.txt", "w"); //(did not work) //f=fopen("C:/Users/min2/Documents/asd.txt",…
drop90prog
  • 45
  • 8
0
votes
2 answers

ASP.Net app calling DLL with fOpen

I have ASP.Net web app and my c# code calls into a custom COM DLL. The DLL was written awhile back and uses fOpen. he fOpen calls return a NULL pointer. I am suspecting it is permissions, but I am having no luck in recolving the issue. Can anyone…
LilMoke
  • 3,176
  • 7
  • 48
  • 88
0
votes
1 answer

PHP/FPDI: "Warning: fopen: failed to open stream: No such file or directory in." and "atal error: Uncaught InvalidArgumentException: No stream given."

I'm trying to get an existing PDF file from a local path in my project, using FPDI/FPDF. I followed the instructions, trying making it corectly, but always I try the command to import the PDF file (even in my localhost or my server) I receive the…
Vinicius Ruiz
  • 11
  • 1
  • 1
0
votes
0 answers

Using fopen() and fread() for a search feature for website

So I been at this for hours and maybe someone can shed some light on me. I have this array of files to be searched in. $searchfiles = array( "index"=>"Home" ); Next I have a loop which goes through the array to search for the keyword I typed in a…
Carlitos
  • 419
  • 4
  • 20
0
votes
1 answer

QT QIODevice equivalent of "a+" (read, but append only)

We have a very high performance application - or, more accurately, a scalable application that needs to write to log files. Each instance gets it's own log file, but when looking at performance metrics, we occasionally see very slow write times. The…
J. Gwinner
  • 931
  • 10
  • 15