All Questions
114
questions
0
votes
0
answers
49
views
How can I get this STDIN to work in GAS Assembler running on Linux?
I am new to Assembler and am currently reading a book about it by Jonathan Bartlett called 'Learn to Program with Assembly'. On pages 160-1 he gives the following sample program to demonstrate the use ...
1
vote
1
answer
182
views
How to check if input is empty?
How to check if user inputs nothing and presses enter only? If that happens then error message and code stops. In C language.
I tried == '\n' and " " but nothing works :(
int main() {
...
0
votes
1
answer
43
views
Why does scanf work the first time it's used but not the second?
So I'm simply trying to accept input from the user in the form 1 2,or 0 0, 2 2, 0 1, etc.
If the user enters this the first time around then everything works as expected. However, if they get the ...
0
votes
1
answer
48
views
Read lines from an input file of varying line sizes
Currently, I am using getline to read lines from a file and I can access individual characters the following way from stdin:
char buffer[1024];
while((lineSize = getline(&line, &len, stdin)) !=...
0
votes
0
answers
30
views
Problem with scanning many integers in a row
When trying to read about 2000 int numbers, scanf() stops working after 1040 ints. How can I solve this problem?
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main()...
-1
votes
2
answers
264
views
reading string from a file via stdin in c11
So I have a .txt file that I want to read via stdin in c11 program using scanf().
The file is essentially many lines made of one single string.
example:
hello
how
are
you
How can I know when the file ...
3
votes
1
answer
75
views
Is there an elegant way to handle the '\n' that gets read by input functions (getchar(), fgets(), scanf()) in C?
I am trying a simple exercise from K&R to append string2 at the end of string1 using pointers. In case of overflow i.e. buffer of string1 can't contain all of string2 I want to prompt the user to ...
1
vote
0
answers
35
views
Function inputElements() taking input only once
I am trying to create a program to find the transpose of a matrix my dynamic memory allocation. However, while entering the elements of the matrix I can't input more than one element, its only taking ...
0
votes
0
answers
48
views
How should my program push data for it's own scanf to read?
I'm in a coding competition where I upload my code to the competition host's platform to be compiled and run. The host then supplies my program with data to work on, through stdin. My code uses scanf(...
1
vote
2
answers
314
views
How to stop scanf with less arguments
I need to keep getting 3 values (int, int, float) from the keyboard and only stop the loop when I enter 0.
The problem is that when I enter 0 and press [Enter it keeps waiting for the second and ...
0
votes
1
answer
123
views
problem with output numbers in dart with stdin
The output with numbers does not work, I can only write the first number and after that the application closes.
void main(List<String> args) {
print("Escreva o numero de carros vendidos ...
0
votes
0
answers
53
views
I am trying to take two input dates in vscode in windows in GNU g++ compiler. But I get first date set to zero after I enter second date?
When given the first.date in the first print output the result is good. But as soon as the second scanf line comes into picture it changes the first.date value to zero. So in the last printf line the ...
1
vote
1
answer
123
views
What signals to scanf to read?
In the following snippet, after reading the int the '\n' remains in the stdin, and is read by second scanf.
Is scanf called on the enter, and then reads what is in the stdin, or is it called before ...
4
votes
3
answers
172
views
How to not count 1.0 as an integer
So I need to read an integer from the stdin where the user may input 1.0, however since this is a double I wouldn't want to accept it. However when I try the method below the 1.0 is converted to 1 and ...
0
votes
2
answers
76
views
Reading from scanf results to infinite loop
I'm trying to read information about students using scanf() in a for loop (N times -> N inputted by the user), but the for() loop goes more than that... it doesn't stop at all. I've tried all the ...