C How to read a file into memory in binary mode

Updated on technology 2024-04-13
13 answers
  1. Anonymous users2024-02-07

    Landlord, you just forgot to close it, and your program doesn't need to be overhauled.

    #include

    #include

    using namespace std;

    int main()

  2. Anonymous users2024-02-06

    file*fp = fopen("","rb");Open in binary fashion.

    fseek(fp,0,seek_set);

    fseek(fp,0,seek_end);

    long longbytes = ftell(fp);l Get the length of the file.

    char buffer = (char *)malloc(longbytes);Apply for space.

    fread(buffer,longbytes,1,fp);Read the file into the buffer

  3. Anonymous users2024-02-05

    Take a look here and see if it's what you want.

  4. Anonymous users2024-02-04

    insert into imagetest values ()

    In two steps, we can easily read the ** file and store it in the database.

    select image from imagetest where variable here#

    #tostring(

    In two steps, we can easily read the information from the database and display it on the page.

    Summary: In fact, in addition to the ** file can be processed in this way, other files can also be processed in a similar way, any file type can be stored in the database, but the reason for the file size and the database storage read speed performance limit, we basically do not recommend storing the file to the database, after all, the hard disk read is much faster.

  5. Anonymous users2024-02-03

    and other types of meanings, no need to be special, after taking out, use the corresponding image class variable to save.

  6. Anonymous users2024-02-02

    Database Oracle, development language C

    byte bytes = "select feild from table") as byte;Reads data from the database into byte arrays.

    ms = new memorystream(bytes);create flow img = ; Create an image object from the stream; Save the image object as **.

  7. Anonymous users2024-02-01

    If you simply take the content from the file, it is most convenient to use streamreader, there are two methods for this kind of object, readline and readtoend, the former only takes one line at a time, and the latter gets all at once, you can use the latter, and then use the string split("r ") to return a wrap that starts with "Carriage Return,.""r"and spaces", the array does not contain the delimited content, but the first element of the array you need to judge, is whether the content of the file is "carriage return newline," at the beginning"r"and spaces", there is still a useless information in the header of the file or something.

  8. Anonymous users2024-01-31

    Already known that there is a carriage return in the separator, then I have a suggestion. Use the text mode to read it line by line, and then determine if a line is preceded by r + space. If yes then there is a separator here, if not that merges the current line into the previous line.

    And so on. It's easier to deal with that way. Then convert the string of each segment to byte array output.

  9. Anonymous users2024-01-30

    list, arbitrarily define the length, delete, and add.

  10. Anonymous users2024-01-29

    What is the file format in which the file is stored?

    What kind of are you going to save it into?

    The specific requirements are written, it is best to give an example of the format, I will give you an example, the format in the file is: wo shi zhong guo ren or: hkfhsdfhds

    sdfdfsdfsd.

    If you want to save it as a two-dimensional array or a one-dimensional array, you need to write it well, and I will write it for you.

  11. Anonymous users2024-01-28

    If you're going to use dynamic memory, why not use vectors?

    vectorv;

    string s;

    ifstream ifs("");

    while(getline(ifs,s))

  12. Anonymous users2024-01-27

    int read(file *fp, int **buff){int len = 0;

    char c;

    while(fread(&c,1,1,fp)==1){int i;

    buff = (int*)realloc(*buff, (len+8)*sizeof(int));

    for(i=0;i<8;i++)

    unsigned char t = 1 "No debugging, just play, tune it yourself, don't ask again."

  13. Anonymous users2024-01-26

    Read and write in the form of a file stream. C++ has a special interface, just call it.

Related questions
15 answers2024-04-13

In the standard output of the C++ language, there are hexadecimal, decimal, and octal output formats, but there is no binary output format. So if you want to output binary, you can only write your own functions for output. >>>More

10 answers2024-04-13

If it's a method, I can give you a natural language description of how the decimal integer part n can be converted to binary as follows: >>>More

8 answers2024-04-13

1.Binary 1000 is replaced by 16.

With the 8421 conversion method, that is, from left to right, 8*1+4*0+2*0+1*0=0x8, this is the universal conversion method for all hexadecimal to binary, bit-to-bit alignment conversion, multiply by 8421 respectively, and then add up. If the binary number. >>>More

12 answers2024-04-13

What is the base system?

If it's not a decimal one: >>>More

9 answers2024-04-13

#include

using namespace std; >>>More