fopen

opening a file with fopen

I've been trying to open a file and output text, but I keep getting errors. So I thought I would start at the very beginning and just try opening the file. This is my code: #include <stdio.h> #include <stdlib.h> #define CORRECT_PARAMETERS 3 int main(void) { FILE *file; file = fopen("TestFile1.txt", "r"); if (file == NULL)...

Fopen failing for binary file

I have a huge binary file which is 2148181087 bytes (> 2gb) I am trying to do fopen (file, "r") and it failed with Can not open: xyz file (Value too large to be stored in data type) I read on the man page EOVERFLOW error is received when the file size > 2gb. The weird thing is, I use a different input file which is also "almo...

Opening a file with path in malloc

I'm trying to open a file with fopen, but I don't want a static location so I am getting the string in from the user when he/she runs the program. However if a user does not enter one a default file is specified. Can I just put the malloc var in to the fopen path parameter? char *file_path_mem = malloc(sizeof(char)); if (file_path_mem ...

[Solved] Server-side, get progress on sending file

Hello fellow programmers. Basically, what I want to do is to check how much of a file my webserver has sent to a client, when the client is downloading one. Is this even possible? Does apache provide any module/extension that would help me accomplish my task? I use a linux distro, apache2 and php5. Regards. ...

Why does fsockopen have performance problems and not fopen when sending a POST request in PHP?

I have tried two different implementations for simulating POSTing a form. One uses fsockopen (example here: http://www.faqts.com/knowledge_base/view.phtml/aid/7962) and the other uses fopen (example here: http://netevil.org/blog/2006/nov/http-post-from-php-without-curl). I ran into some serious performance problems with fsockopen - whe...

PHP fopen filename. Is it relative or absolute?

Hi I'm having problems with my paths and fopen with reference to my web server. I have a file saved in public/dan/new/apps/lovescopes/thisfile.php. thisfile.php will create a new file in public/internalServer/lovescopes/xml/2009/12 using fopen "x+". now my errors show in the line where fopen is: 1.) if i type in the path as relative ...

How can I use graphical resources (stored in res\drawable folders) from NDK?

Hello! I need to use openGL in NDK, and I need to load and use some images (PNG), and maybe other files. These files are stored in res\drawable, res\drawable-hdpi, but I cannot access them with fopen()... There is a way to do this? Can somebody give me a piece of code for my problem, because it is quite urgent. Thank you very much, and...

Cloned object should use single file handle or each one has their own?

I am working on a wrapper that parses a data file for an existing web tool. However, I am using large data files so I cannot load the whole thing into memory so I have to walk through it loading it in small chunks. The existing web tool expects data in a style similar to SimpleXML ($obj->parentnode->childnode->childnode returns a strin...

What encoding used when invoke fopen or open?

When we invoke system call in linux like 'open' or stdio function like 'fopen' we must provide a 'const char * filename'. My question is what is the encoding used here? It's utf-8 or ascii or iso8859-x? Does it depend on the system or environment setting? I know in MS Windows there is a _wopen which accept utf-16. ...

Streaming local file from PHP while it's been written to by a CURL process

I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a different discussion. Here's the code: shell_exec("nohup curl --create-dirs -o {$write_path} {$source_url} > /dev/null 2> /dev/null & echo $!"); sleep(1); $read_speed = 65.5; # 65.5 kb/s download rate $handle = fopen($wri...

Cant open a https website with php and fopen

I am using fopen to retreive the contents of a URL. It works on http URLs but not https URLs Can anyone see why?? <?php //this works fine echo ("<br><br>url 1 is ".OutputURL("http://nuenergy.acornsoftware.com.au/staff/interface/index.php")); //returns nothing echo ("<br><br>url 2 is ".OutputURL("https://nuenergy.acornsoftware.com.au/...

After fopen, can I search for a keyword in PHP?

If I use fopen on a file, is there any way to scan through the file to find the number of bytes a certain keyword begins at? If not, how can I do this? ...

writing to log file causes error 704

Hello, Does anyone know what this error means FATAL: Autorisation no longer valid.704 It happens when I try to write to this file, but the permissions are set to 755 and 0644 The temp folder is in the rootfolder of this subdomain. if ($handle = fopen( 'temp/mylog.log'"a+") ) { if( !fwrite( $handle, $json ) ) {...

What are the biggest differences between fopen and curl ?

I am making a web application in PHP and want to read content from a other domain. For that i have to options fopen and curl but what are the differences like security / options etc.? and what is the best way to use and why ? does it matter if the url from the other domain is a http or https site ? ...

VB.Net - opening a file which may be local or remote (via http)

Hi all, I wonder if someone can help me; In PHP you can use fopen(Path) to read from a file. The Path can be either a local file (in the usual formats /etc/file or c:\file.txt) OR it can be a URL in which case PHP will open a http connection and read from the remote location I'd like to achieve the same in VB.Net. I'm not aware of any...

Need help to get an html and use in C like a text file in fopen

Hello, I want to get a HTML and use like a file in C. Actually I can do that, but I have to save the file first on the disk and then use fopen("/file.html", "r");. What I would like to do is to extract the html directly from the URL and work with it. Hypothetically, fopen("http://www.google.com", "r"); I saw something about libcurl bu...

Create files from file names in another file C++

Hi, I am working on sorting several large files in C++. I have a text file containing the names of all the input files, one on each line. I would like to read the file names in one at a time, store them in an array, and then create a file with each of those names. Right now, I am using fopen and fread, which require character arrays (I ...

file doesn't open using PHP fopen

i have tried this: <?php $fileip = fopen("test.txt","r"); ?> this should have opened the file in read only mood but it doesn't the test.txt file is in same folder as that of index.php (main project folder) the file doesn't open and when i put echo like : echo $fileip; it returned Resource id #3 ...

PHP fopen returning null on files that work fine with include and get_file_contents

Hi, I have XAMPP installed on a windows 2000 server. everything is working great except the PHP fopen function. I can neither create nor open files with it. the strange thing is that i can include/require/file_get_contents/other file related functions; also fopen does not generate any errors or notices it just returns NULL. I have gone...

How to create custom filenames in C?

Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i = 0; FILE *fp; for(i = 0; i < 100; i++) { fp = fopen("/*what should go here??*/","w"); //I need to create files with names: file0.txt, file1.txt, file2.txt etc //i.e. file{i}.txt } } ...