| |

VerySource

 Forgot password?
 Register
Search
View: 626|Reply: 2

How does fwrite write int data? Online etc. >>>

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-18 17:40:01
| Show all posts |Read mode
I use fwrite to write int-type data, and all that is written to the file are: ) I do not know how it is?

code show as below:
FILE * file;
   char list [3000];
   int i, numread, numwritten;

   / * Open file in text mode: * /
   if ((file = fopen ("fread.txt", "w + b"))! = NULL)
   {
      for (i = 0; i <3000; i ++)
         list [i] = (char) 3456;
      / * Write 25 characters to stream * /
      numwritten = fwrite (list, sizeof (char), 3000, file);
      printf ("Wrote% d items\n", numwritten);
      fclose (file);

   }

Help, wait online, urgent! ~
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-30 23:54:01
| Show all posts
int n = 1234;
fwrite (&n, 1, sizeof (n), file);
The binary data is written. It cannot be viewed directly with a text editor. If you open it with a binary editor, you will see hexadecimal data.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-18 16:45:01
| Show all posts
New learning,
Open with an editor such as UE, Notepad can only read text characters
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list