Debugging using input file OS X - c

I searched for a solution to my problem already in Google and here in stack overflow.
I didn't found an understandable and precise solution for my problem:
I've written a program that maintains an inventory.
It compiled without warnings or errors and it works quite well when I type in commands by hand. When I'm running the program with an input file with much more parts I get a segmentation fault 11.
Now I want to debug my program but don't know how to do this using input files.
I already did some debugging via the CodeBlocks IDE. Didn't find a option for this.
I used malloc and realloc functions in my program and think the error happened there because I never used it before.
Could you please help me in following ways:
I need a debugger that can debug while the program runs with an input file.
The debugger must be able to check for memory leaks or things like this.
Thanks
Armin

Debugging with command line input vs. Debugging with a input file is the totally same.
You must understand this.
When you start debugging session in the IDE, it is by default 'no input' mode (no input file).
But you can specify startup conditions for the program, including working directory, command line arguments, etc.
By using these options, you can run the debugging session exactly same as user running the program with input files.

Related

Facing an issue int the terminal of VS code

I am very new to coding, it being only 3 weeks until I have started to learn to code. I write very small codes as of now (like only 20-30 lines, maximum 44) Whenever I write a code, then run it, as you might know, that if I have written a code for finding if the number is prime or not, I have to write in the terminal, ./prime and then press enter, then input a number.
But, when I do that in my VS code software, when I write, ./prime and then press enter, it shows:
bash: ./prime: No such file or directory.
I observed that my teacher is using that terminal in git bash, so I installed GitHub and used git bash for it, still, this problem was occurring. My brother predicted that you might not be saving the file, do that and then play it on the terminal. I even did that, but still, it was happening. And this is happening with every code I am typing, all the 44 code files.
Idk if this is happening because I have missed to download a particular file of mingw, or is there a different method to do that, for windows(my OS), because my teacher uses mac
You need to compile your code before you execute.
In terminal run command gcc prime.c -o prime and then you are good to go with ./prime

Beginner: How do I actually use gperf? It just hangs every time I run it

I am very new to coding, currently taking Harvard's CS50x class online. The extent of my familiarity with code, languages, and environments is what they've taught me so far in C. With vague guidance from other questions on this site, I've taken about 4 days to install gperf, from discovering what Cygwin is to installing all of its libraries and error-checking the installation all the way up to finding out where it finally put the installed program. I was so happy when I actually found the application 'gperf.exe' just now. I thought I was finally just about to get the hash function I've been trying to make for almost a week.
And now, the program does nothing but hang every time I try to run it, no error messages. Offering no input file causes it to hang. Doing any amount of and selection of options specified in the manual, it just hangs. Even debugging says it's entering debugging, then just hangs. The only way I've been able to get the program to respond at all is offering it an invalid input file, which it says is invalid. Nothing else does anything; no output file, no command-line response, nothing. I am frustrated to the point of tears, and the documentation provided with gperf assumes you're a professional coder, talking endlessly about the hundreds of high-level customization options to modify the program, but not a word about how to make it just run on a basic level. I've searched Google and this site extensively, and very little pops up as soon as I search for gperf related issues specifically.
Can anyone please just walk me through how to make this program work? I'm sure it's some stupid little thing that I'm missing, but all I want it to do is take my input file of strings and give me a hash function in C. Any and all help is appreciated, I have absolutely no clue what I'm doing and even installing gperf was a multi-day process that is far beyond the scope of what I've done so far.
Thank you.
EDIT:
Executions I've tried passing:
gperf
./gperf
Arguments I've tried passing:
-a
-c
-d
--output-file 'FILE'
I have tried all of these with and without the inclusion of my input file, named 'keys' and 'keys.txt'. The only thing that has generated any response from the program has been giving it an incorrect input-file name, giving the result 'could not load input file 'keys''.
gperf can be slow if the input file you give it is large, that is, contains many keys. You can get an impression of what are "small" files vs. "large" files by looking at the documentation: Known bugs and limitations.

Unable to run C programs using any compiler

I had to write code in C and run it for an assignment. Since this is the first time that I'm using C, I downloaded MinGW as a compiler and Code Blocks as an IDE. I had no problem compiling the code given by my professor but it never runs (this is a simulation for an M/M/1 queue). When I say it never runs, I mean that a command prompt like window pops up and nothing happens after that. Every time I close that window and try to compile the SAME program again, I get an error that says that permission to access the file has been denied.
I then deleted Code Blocks and tried running the program through command prompt but I have the same problem. I've now tried doing it using LCC-Win but nothing has changed. Another weird thing that happens when I run any program is that three instances of the .exe file of that particular program are in my processes under task manager. I then need to restart my computer to try compiling that same program.
I even tried running a simple Hello World program and I have the same problem!
I am currently using a Windows 7 32-bit system.
Any help would be greatly appreciated!

c programming, disable user input into terminal

Hi is there any possible way to temporarily disable user input into the terminal in c programming language?
There is probably a very good reason why you can't (possible malicious uses) but if its possible, can someone please illustrate how? maybe there is a function, a setting or even an obscure system command?
For context: a friend was having issues with a hard drive, so i created a program which ran a few terminal command and printed the output to a text file which he would send me. It all worked fine, however he didn't really know what he was doing so i printed instructions to the console to instruct him in what to do. although this all worked out, the thought did occur that i could potentially disable user input for that particular terminal window until it was required, and thus the question.
Its also a pretty basic question so if its actually a duplicate (although i could not find one) than please label as such.

Compiled C files getting no access error

I'm running the MinGW compiler (gcc port for windows). After messing around with the paths I got it running and compiled a program. Now the executable won't open. If i run it from the command line i get access denied. If i run it from windows explorer i get the same thing but in a popup. Avg is also giving me trojan reports about my own program.
I have no idea of what might be happening with your anti-virus, but I have heard from fellow programmers that antivirus can be very annoying giving false-positives these days. Anyway, check that the program that you generated is indeed giving some sort of "Access denied" error instead of "Access violation". The most likely cause is that your program can not access certain dll's that it needs to run, like libgcc_sj.dll (not really sure about the name), or even some msvcrt??.dll . The easiest way to check for the list of dll's that your program depends upon is with an utility distributed in the Window's SDK called "depends.exe".
Good luck!

Resources