问题描述
这是我写的一些代码。请注意-
-
const useStyles = makeStyles((theme) => { return { root: { minWidth: 275,border: "3px solid black",borderRadius: "5px",boxShadow: "10px 5px 5px red",padding: 0,height: "50vh",// primary height overflow: "scroll",[theme.breakpoints.up(750)]: { height: "80vh" // secondary } },... }; });
> 512字节指向的文件 - 我是否以“ r”或“ rb”打开正在读取的文件?除了几个JPEG,我不知道里面有什么。
- 为什么我的fread总是输出0,即使我将其设置为fread(字节,1、512,原始字节)?
rawbytes
修改1: 将int数据类型更改为size_t数据类型。新代码:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <cs50.h>
int main(int argc,string argv[])
{
// Declaring a new type
typedef uint8_t BYTE;
// Declaring an array of bytes,in which I want to read 512 bytes
BYTE bytes[512];
FILE *rawbytes = fopen(argv[1],"rb");
int numberofbytesread = fread(bytes,1,512,rawbytes);
// Check
printf("%i\n",numberofbytesread);
fclose(rawbytes);
}
我不知道%zu是什么,但是编译器告诉我将%i与%zu交换。仍然读取0字节。 :(
编辑2:为了使问题可重现,我已将argv [1]替换为我要从“ #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <cs50.h>
int main(int argc,string argv[])
{
// Declaring a new type
typedef uint8_t BYTE;
// Declaring an array of bytes,in which I want to read 512 bytes
BYTE bytes[512];
FILE *rawbytes = fopen(argv[1],"rb");
size_t numberofbytesread = fread(bytes,rawbytes);
// Check
printf("%zu\n",numberofbytesread);
fclose(rawbytes);
}
“恢复” JPEG文件中使用的存储卡文件。这段代码只是我编写的一小段代码,用于检查我是否能够从card.raw
执行card.raw
下载具有此问题分布的(压缩的)ZIP文件。
执行wget https://cdn.cs50.net/2019/fall/psets/4/recover/recover.zip
解压缩该文件。
unzip recover.zip
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)