gpt4 book ai didi

c - 尝试在使用 C 从存储卡中获取的原始文件中查找 jpeg 文件

转载 作者:太空狗 更新时间:2023-10-29 15:36:26 25 4
gpt4 key购买 nike

您好,我正在尝试在原始文件中查找 jpeg

有人告诉我每个 jpeg 的开头都以
- 0xff 0xd8 0xff 0xe0
- 0xff 0xd8 0xff 0xe1

所以我这样做:

// open input file 
FILE* inptr = fopen("card.raw", "r");

// create an array to hold info read from the memory card
char buffer[512];


int counter=0;
int counter2=0;


while ((fread(buffer, sizeof(char), 512, inptr)!=0))
{

if(buffer[0]==0xff)
{
counter++;
printf("%2d - Found a jpeg!\n", counter);

}

else
{
//Just to test
counter2++;
printf("%2d - Nothing Found!\n", counter2);
}
}

但是即使我确信那里有一些图像,程序也没有找到任何东西。预先感谢您的建议。

最佳答案

找到答案了!!,我需要像这样将缓冲区声明为无符号字符:

unsigned char buffer[512];

关于c - 尝试在使用 C 从存储卡中获取的原始文件中查找 jpeg 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12961531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com