binaryfiles

Unsuccessful fread() of int stored in binary file, segmentation fault [closed]

自古美人都是妖i 提交于 2019-12-17 02:04:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . There seem to be of the order of 10 questions and (mostly) successful answers solving segmentation faults cause by misused fread()'s in C. That being said, I am having such a problem but have not found a solution. I have a binary file containing an int (call it nbins ) and an array of float s (of size nbins ).

C binary read and write file

为君一笑 提交于 2019-12-14 04:13:17
问题 I am using a binary file for reading an array of integers, then each even integer x should become 2 * x and each odd integer x should become 3 * x. When I am doing this it always read the 2nd integer (which is 2 ). Any idea? #include <stdio.h> #include <stdlib.h> int main(void) { FILE *f; f = fopen("inputData.txt", "w+b"); int n = 5; int i; for (i = 1; i <= n; ++i) { fwrite(&i, sizeof(int), 1, f); } int x; fseek(f, 0, SEEK_SET); while (fread(&x, sizeof(int), 1, f) == 1) { printf("%d ", x); if

Copying binary files using fread and fwrite

你。 提交于 2019-12-14 03:30:31
问题 I have a problem when copying binary files using fread and fwrite : the loop runs only two times (40 bytes), but the file length is 160 bytes: #include <string.h> #define PER_READ 30 int main(void) { char buffer[500] = { 0 }; FILE* CSV = fopen( "CSV.csv", "rb" ); FILE* csvDest = fopen( "CSVDest.csv", "wb" ); unsigned int finished = 0; unsigned int counter = 0; do { finished = fread( buffer, sizeof( char*), PER_READ, CSV );//Read all from CSV to a string name buffer finished += PER_READ *

How to convert video file(.mp4, .3gp) format into binary format in android

喜夏-厌秋 提交于 2019-12-14 03:01:21
问题 I had captured a video from camera and stored in sd card, now i need to convert that video file into binary format for my process. Can any one tell me how can i convert video files into binary format. Thanks in advance!!!! 回答1: I converted my image files and pdf file with the following method, try this with your requirement Bundle objBundle = objResult.getExtras(); Uri uriString = Uri.parse(objBundle.get("").toString()); File file = new File(uriString.getPath()); FileInputStream objFileIS =

Reading IBM floating-point in C++ [duplicate]

心不动则不痛 提交于 2019-12-13 23:03:42
问题 This question already has an answer here : IBM Single Precision Floating Point data conversion to intended value (1 answer) Closed 10 months ago . I have a a binary file format with a bunch of headers and floating point data. I am working on a code that parses the binary file. Reading the headers was not hard but when I tried to read the data I ran into some difficulties. I opened the file and read the headers as the following: ifs.open(fileName, std::ifstream::in | std::ifstream::binary);

How to read binary executable by instructions?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 19:13:32
问题 is there a way to read given amount of instructions from a binary executable file on x86 architecture programmatically? If I had a binary of a simple C program hello.c : #include <stdio.h> int main(){ printf("Hello world\n"); return 0; } Where after compilation using gcc , the disassembled function main looks like this: 000000000000063a <main>: 63a: 55 push %rbp 63b: 48 89 e5 mov %rsp,%rbp 63e: 48 8d 3d 9f 00 00 00 lea 0x9f(%rip),%rdi # 6e4 <_IO_stdin_used+0x4> 645: e8 c6 fe ff ff callq 510

Best way to read/parse a untyped binary file in Delphi

房东的猫 提交于 2019-12-13 17:06:52
问题 I would like to know what is the best way to parse an untyped binary file. For example, a EBML file. (http://ebml.sourceforge.net/). EBML is basically a binary xml file. It can store basically anything, but its predominate use right now are MKV video files (matroska). To read a EBML file at the byte level, reading the header making sure it is a EBML file and retrieving information on the file. MKV files can be huge, 1-30gb in size. The binary file could be anything, jpeg, bmp, avi etc ... I

C#: Write values into Binary (.bin) file format

左心房为你撑大大i 提交于 2019-12-13 12:22:35
问题 So lets say I have the following values: HEADER01 48 45 41 44 45 52 30 31 06/17/14 30 36 2F 31 37 2F 31 34 1.0 31 2E 30 0x0000 00 0x0027 27 0x0001 01 0x0001 01 0x0001 01 0x0001 01 0x0028 28 192 C0 168 A8 1 01 1 01 The first 3 values are STRINGS, should be converted to ASCII HEX values, then written in the .bin file The next 7 values are HEX, should be written AS-IS in the .bin file The last 4 values are INTEGERS, should be converted to HEX, then written in the .bin file OUTPUT (.bin) file

How to pass an Excel file from a WinForms client to a WCF service and into an SQL Server table?

大憨熊 提交于 2019-12-13 09:37:32
问题 How to pass an Excel file from a WinForms client to a WCF service and into an SQL Server table? Can anyone provide any guidance, code, or advice? WCF service contract and implementation that will take an Excel file as a parameter Contract implementation should insert that Excel file into a varbinary(MAX) column in SQL Server. 回答1: Here is a post that addresses the WCF portion of your question. Once you get the file to the server you can use FileHelpers.net to parse that file into an object. I

compression algorithm

家住魔仙堡 提交于 2019-12-13 09:32:00
问题 I'm working on a compression algorithm wherein we have to write code in C. The program takes a file and removes the most significant bit in every character and stores the compressed text in another file. I wrote a function called compress as shown below. I'm getting a seg fault while freeing out_buf. Any help will be a great pleasure. 回答1: You close out_fd twice, so of course the second time it is an invalid file descriptor. But more than that, you need to review your use of sizeof() which is