Questions tagged [fwrite]

fwrite stands for file write. It is a function available with PHP, C, C++, etc. for writing the contents of string to the file stream pointed to by handle.

fwrite stands for file write. It is a function available with PHP, C, C++, etc. for writing the contents of string to the file stream pointed to by handle.

PHP fwrite

Visual Studio fwrite

C++ fwrite

1762 questions
0
votes
1 answer

Writing bytes to file gets swapped on certain platforms

The following code gives me different outputs on different systems: int fd = open(filename, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); byte_t data[] = { 0x00, 0x01, 0x02, 0x03, 0x0a, 0x0b 0x0c, 0x0d }; write(fd, data, sizeof(data)); On the…
user1660675
  • 149
  • 3
  • 10
0
votes
2 answers

fclose, fopen and fwrite issues with writing multiple files

I have a program that records data from a serial port. Every so often, I want to split up files such that the data logs don't become very large. The problem is, after I recreate the FILE* and try to write into it, the program crashes. No compiler…
user2619824
  • 478
  • 1
  • 5
  • 20
0
votes
2 answers

How to convert vector to string and convert back to vector

----------------- EDIT ----------------------- Based on juanchopanza's comment : I edit the title Based on jrok's comment : I'm using ofstream to write, and ifstream to read. I'm writing 2 programs, first program do the following tasks : Has a…
dulipat
  • 171
  • 2
  • 4
  • 12
0
votes
1 answer

PHP writing text file cuts text off from end of string

In my code I have to write multiple json strings to files. When I do so, the end of what's being written is cut off by a seemingly random amount of characters. I originally tried using fwrite(), then tested using just file_put_contents(), but both…
iRector
  • 1,935
  • 4
  • 22
  • 30
0
votes
2 answers

C reading a File in binarymode and write to an output file

I created a File of 4000 blocks with a blocksize of 4096 Bytes. I wrote to some specific blocks in this file and now I want to read these blocks and write the result into a new output file. Therefore I open the file I created in "rb" mode…
SevenOfNine
  • 630
  • 1
  • 6
  • 25
0
votes
1 answer

Create text file out of query results

I need to create a text file from a foreach loop (code below) but i'm not sure how. So far I have tried to use fwrite but I'm not to sure how to write that much data to a txt file. I also tried to use file_put_content(), it worked but it displayed…
Tony
  • 3
  • 1
  • 6
0
votes
2 answers

I have an issue with fwrite not properly overwriting a file

For some reason, when I use fwrite to overwrite the contents of my file, it erases the data, but fails to write the new contents to it until fwrite is invoked a second time. Is there any way I can get around this? My script uses HttpRequest to send…
Logical Angel
  • 91
  • 2
  • 10
0
votes
1 answer

Save remote file on FTP

I am trying to download a file from a remote website using cronjob and save it on my hosting. For this purpose I am using the following function but unable to achieve the desired results. When i run the function no file is downloaded. function…
Saad Bashir
  • 4,341
  • 8
  • 30
  • 60
0
votes
2 answers

Writing to CSV Issues

The output file doesn't seem to be placing data properly into the CSV include_once ('database_connection.php');//Including our DB Connection file if(isset($_GET['keyword'])){//IF the url contains the parameter "keyword" $keyword = …
Ben P. Dorsi-Todaro
  • 221
  • 1
  • 6
  • 20
0
votes
2 answers

PHP version: 5.1.6: Cannot write to file

I am using version 5.1.6 and am observing a strange issue. I cannot create and write to a file from the script whereas if I explicitly create a file and then run the script it writes data. Am I missing something obvious in here? The test code I am…
iDev
  • 2,163
  • 10
  • 39
  • 64
0
votes
1 answer

PHP display first 6 line of txt file

I have here my php code and txt file. I want to display 6 lines in .txt file randomly at the output of php. How can i do it. I try my code but it only display the first 6 lines. Thanks! Php: require_once "config.php"; $txt_file =…
user2651946
  • 21
  • 1
  • 8
0
votes
3 answers

Php write some variables in the same line

I would like to ask a simple question. I have different variables $a='a', $b='b', $c='c' in PHP. I would like to save the target txt file with the format like "a b c". But if I use fwrite, I could only write the variables in a column. "a b …
user2152814
  • 257
  • 1
  • 7
  • 17
0
votes
0 answers

Matlab multiple connections tcpip

I have 6 led lights ruled by a matlab program through wifi. I can change smoothly the light spectrum of just one of them using matlab's tcpip command. However, if I want to send the desired spectrum to all of them at the same time, I have to use…
0
votes
1 answer

fgets / fwrite loop php

am having a problem with a loop. i have a text file which looks like this AN Xixerella AN Vila AN Sornas AN Soldeu AN Sispony AN Segudet AN El Tarter AN Sant Julia de Loria AN Sant Joan de Caselles to the exception that i have more than 2…
khalid sookia
  • 317
  • 2
  • 13
0
votes
1 answer

How do I properly use fread() and fwrite() in my program?

/*Write a program that indefinitely takes in files to append to a master file. If the file names are the same, don't do it. If there's an error, don't do it. Exit with a blank line. Use a custom buffer.*/ #include #include…
Theo Chronic
  • 1,623
  • 2
  • 15
  • 16