Segmentation Fault when run loop 41881 times [closed] - c

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.
I am writing a C program that reads a text file and parses the data in it into various fields. The text file I am reading from is very large though (31MB) and when I run the program on a text file that has 41880 lines of input everything works fine. I will ultimately need to read from text files that are much much larger than that though. So when I increase the lines to 41881 though I get a segmentation fault. Any ideas?

You are trashing memory somewhere along the way and it's finally hitting you at line 41881.
If your platform is supported, try running under Valgrind.

Related

Searching for opcode bytes in PE file [closed]

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).

Get Size Of File From Commandline Input In C [closed]

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.

How to delete a specific line from binary file? [closed]

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.
How to delete a specific data from binary file. Please example, thanks :)
Binary files have no lines, but to delete any block of data from any file you just need to write the data after this block starting at this block beginning and truncate the tail.
EDIT: to delete specific data you have to find the data and then read the first paragraph again :)
Binary data could have various types of structure, but not 'lines'. A priori, I recommend that you use some established library designed for however your data is formatted be it binary XML, Berkeley DB, whatever.

How to create a file with a given size? [closed]

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 create a file in C with a given file size. Is it possible?
Create the file.
Write bytes to it, until you've written the size you want.
Close file.
The loop should be all of about 2 lines of code.
What difficulties are you encountering?
create the file
seek to the desired size
write 0 bytes
close the file.

How to read an image file from hard to memory using C [closed]

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 ?

Resources