It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm trying to get the size of a file from the commandline in C using argv. I'm not too familiar with file i/o in C, so any pointers would be greatly appreciated. Thanks.
You've not stated the platform, but your C program is given an argument list when it is started, and the file names are strings. The POSIX function you'd probably use is stat(); it takes a pointer to a struct stat and will put the file's size into the st_size member of the structure.
The answer may be different on Windows; the POSIX subsystem will provide a stat() workalike (probably named _stat()), but there'll also be a native interface.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
As we can see a macro defined in stdint.h or bits/types.h etc.. which is __WORDSIZE. I don't know where to check out whether this macro is defined. Also, is there a way to checkout different size of the basic types without using the sizeof in c. I mean, is there a document exhibits the size of those variables?
Well, it depends on the platform. First, there are some requirements set by the C standard and/or the POSIX standard if you use UNIX. Things like sizeof(int) <= sizeof(long) or sizeof(char) == 1
Then the ABI has the final say. For example, on linux/freebsd/solaris on x86_64, they use a common ABI: http://people.freebsd.org/~obrien/amd64-elf-abi.pdf
3.1.2 in this document has the size for all types for this ABI
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a task of searching for opcode bytes in a PE file and checking whether a specified opcode byte sequence (constant and predefined) is present in the PE file. I have come across numerous examples online, but the solutions are mostly in C# or Python; however, my requirements are based in C language.
Please tell me how can I check and compare opcode byte values in a PE file by writing a simple program in C. Any help will be greatly appreciated.
Thanks.
You may take a look at ROPGadget or at rp, both software contain code that do what you want (and more).
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
ok guys,
this is a very good question in C code (not c++):
void *pName=function();
i'd like within "function()" to get the name of the pointer "pName", of course without passing it as an argument string to the same function.
and if you are really so good in C you can provide me the type of pointer, i mean for example:
char *pName=function();
i'd like to get name and type , so "pName" and "char" within the function.
thank you :)
This is not possible. The best you could do is write a macro (shudder) that passes the type and name as arguments to the function without you having to write them a second time.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I want to read an image(JPEG) file from hard disk to memory. How can I do this? What kind of variable type should I use ?
Use a big char array
char data[4096]
And fread(3) chunks into it. Of course an entire JPEG won't fit in 4096 bytes, but perhaps you can work with chunks instead of the entire file ?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Using C, how do we find the max size of char* allowed by a file system?
My assumption here is that you are asking for "What is the maximum allowable length of a file name allowed by a file system?"
This is dependent on the OS and how the filesystem is implemented, but most systems have defined macros that can be referenced.
In Linux, limits.h, the value can be reference by the macro PATH_MAX, 4096 (Current as of kernel 2.6.35)
In Windows, WinDef.h, the value can be reference by the macro MAX_PATH, 260 (Current as of Windows 7). This does not include the use of UNC paths (See comment below).