Skip to content
Advertisement

c code to compare two binary files runs on windows but won’t run on Linux [closed]

I wrote a c code on visual studio to compare binary file to search a know virus in other binary file.
the code is running on my windows PC perfectly however it won’t compile on the Linux test of my collage.

the code receive a folder containing the files and the file of the virus


this is the code adjusted for Linux that i sent to the test

JavaScript



this is the code I run on windows, I add the dirent.h library to open the folder directory

JavaScript

Advertisement

Answer

Pasting your code into godbolt quickly reveals the problem. struct stat isn’t defined. For linux, you need to #include <sys/types.h> and #include <sys/stat.h> for struct stat. Pay attention to the remaining warning(s).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement