Lex program input doesn't terminate [closed] - c

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm not able to terminate input for a lex program even after pressing ctrl D it just keeps going on!
What might be wrong? I am using flex compiler for Windows.

On Windows:
You need Ctrl+Z then Enter instead of Ctrl+D, which is available in Unix and Linux (on Linux just Ctrl+D will work)
Note: Both work on empty lines, so after entering any text, press Enter to go to next line (which will be empty), then these key combos will be effective.

Related

How to get input from user via command line while bison/flex reads file? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
I'm new to flex and bison and i couldn't figure it out. I want to read a file. This is okey for now. But while bison/flex parse and read file, I want to make it wait for new input and get it from command line. Is there a keyword or way to do it?
I tried abort yyparse() with yyerror() and get input by scanf(). But it didn't work. It doesn't wait for input and goes on.
I did a project school named mini_shell and what we asked to do was to code something like bash.
the main thing was to wait for user input and execute the command he entered, you can do that by a function named.
char *readline(const char *prompt); (you can read the man page to understand more https://man7.org/linux/man-pages/man3/readline.3.html) but I think you need to install it first before you can use it, you can find a lot of tutorials explaining how to do that based on your OS.

.exe doesn't close properly in C [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am a beginner in C, I wrote a code to calculate the average of grades, it's fairly simple, but it won't close properly when I run it in the .exe. I'll attach a video showing how it works, first I run it from the code, then from the .exe.
Video
Whatever the IDE is you're using, it is using a runner.exe to wrap the execution of your program and show you that "program stopped, hit any key" sort of prompt.
That doesn't happen for a compiled program, and the console window is closed right away at your exit(-1) call.
If you want to see the final output of your program, run it via the command prompt.
You can use exit(0) instead of exit(-1).

Count amount of words, characters, newlines in C [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I know it is not recommended to post code as an image, since I am getting a formatting error when trying to post code on here. Anyway, I am trying to write a simple C program to count number of words, characters, newlines using do while loop. However, the output is not as expected. Please help!
Instead of a do-while, you should try using while. Since your code starts off by checking whether a is any of your if cases, it goes to the else case, and increments the New line variable. If possible, could you share the output screen.

File ends without newline [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
the ARM program for lpc2148 basic program.that is an warning for last line of file ends without a new line.
the program code for this
The warning means exactly what it says, "last line of file ends without a newline". The solution is to edit the file so that it ends with a newline.
Open the file in the editor.
Place the cursor at the end of the last line.
Type [Enter] (to add a newline).
Save the file and recompile.

Write function in linux kernel module is called repeatedly [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am writing a character device driver in C for Linux and have run into a problem where my module_write function is being called repeatedly. What could be causing this?
Attached is a screenshot of the command used to write to the device file and the kernel log output
As you can see, it looks as though the module_write function is being called repeatedly. It doesn't matter how I write to the file (I tried using vim, echo and tee)
Source: https://gist.github.com/SamTebbs33/8ed6a1d165fae1ca27fff5b495d04797
You keep saying that 0 bytes were successfully written, so the program keeps trying to write its three bytes.
You should instead be returning the number of bytes you processed successfully from the buffer.

Resources