#include <stdio.h>
int main(){
FILE * fp;
char* a="all_new";
fp=fopen(data.bin,"wb+");
fwrite(a,200,1,fp);
}
I saw the data.bin
There are trash values. I want to fill up the parts that exceed 7 with CC CC CC... What should I do?
stdio.h visual-studio
A is 8 bytes including NULL characters, but it's a problem because I wrote 200 bytes in the file.
#include <stdio.h>
#include <string.h>
int main(){
FILE * fp;
char a[200];
memset(a, 0xCC, sizeof(a));
strcpy(a, "all_new");
fp=fopen("data.bin","wb+");
fwrite(a,200,1,fp);
fclose(fp);
}
memset is a function that initializes the buffer to the specified character. Doing so as above will initialize the a buffer to 0xCC. strcpy is a command that copies a string Copy "all_new" to the a buffer. And he added the part that closes the file at the bottom.
578 Understanding How to Configure Google API Key
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
917 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.