Questions tagged [stdio]

This tag is for questions regarding "Standard I/O", i.e. I/O using the facilities in the C header or using the standard streams stdin, stdout, stderr.

The C standard header <stdio.h> defines facilities for using data streams via FILE objects and also declares the pre-defined standard streams, stdin, stdout and stderr.

The standard IO streams can be used from C in two ways:

  1. Using standard IO streams as implemented by the standard header <stdio.h> e.g. fprintf (stdout, "hello, world\n");
  2. Using the underlying file descriptors directly using the facilities in <unistd.h> e.g. write (STDOUT_FILENO, "hello, world\n", 13);. Note that this is not ISO C, but POSIX.
1090 questions
-1
votes
1 answer

How to make my C++ infinite loop program only receive linux pipe input just once for one time?

I have a c++ code like this: #include using namespace std; int main() { char str[20]; while(true) { cin>>str; cout<<"Your input is "<
-1
votes
1 answer

How to fix "The input/output library shall not be used."

Rule 22 in JSF AV C++ Coding Standards says: AV Rule 22 (MISRA Rule 124, Revised) The input/output library shall not be used. I understand from this answer why I shouldn't use these functions, but so far I didn't find an answer to what I…
אנונימי
  • 304
  • 2
  • 7
-1
votes
1 answer

How to copy the content of a binary file into an array

I am currently working on a chip-8 emulator and I have a method which loads in the program by copying a binary file into an array called 'memory'. However, it doesn't work as mentioned on the tutorial page and I'm a little bit confused. I've already…
leon4aka
  • 3
  • 3
-1
votes
1 answer

How can I find source code of printf in macOS?

Sorry for my bad english. I'm using macOS 12.3 in M1 Pro MacBook Pro I want to know about source code of printf in C standard library. I can find stdio.h file in usr/include directory. But I can't find printf.c or stdio.c file in same directory. And…
-1
votes
2 answers

Undefined behavior of printf in C?

What should be the output of a single percent sign? #include void main() { printf("%"); } "Unknown format code" is not like "Unknown escape sequence".
Polluks
  • 525
  • 2
  • 8
  • 19
-1
votes
3 answers

Why "ios::sync_with_studio(0) and cin.tie(0);" doesn't work with strings in C++

I was solving one problem using C++ where I have to take a string as an input. So instead of using the standard input/output method, I tried to use fast input/output method. #include using namespace std; typedef long long ll; int…
-1
votes
1 answer

No module named 'stdio'

I have "stdlib-python" and "guess.py" under the same folder named "Projects". I'm trying to use "import stdio" in guess.py, but when I it or any available modules in "stdlib-python", it red lines the module name and say "No module named '(module…
-1
votes
1 answer

CSV file row average in C

I have a CSV file with 5 rows and 10 columns (each row containing 10 elements in form of decimals). I need to write a program that opens and reads the file and takes the average of each row . void exercise3(){ FILE*…
kasra
  • 1
  • 1
-1
votes
1 answer

Reading a file to memory using standard C library - Windows prematurely identifies EOF but works on Mac,Linux

This feels like the dumbest problem, but hopefully someone can help. Sorry the post is so long, but I wanted to provide sufficient detail so that folks don't suggest things I've already tried. I have isolated a problem with a C program that I wrote…
brant
  • 369
  • 3
  • 8
-1
votes
1 answer

I'm a student and I can't run program in C (visual studio), when I include a library like stdio.h

I'm in class where we're learning C, and a few weeks ago I noticed whenever I included any library with #include an error takes place. For this simple piece of code: #include #include int main() { printf("Hi");…
-1
votes
1 answer

Pthread Programming Short Example

I am having some trouble understanding this code since I am new to pthread programming. From what I understand, we create N threads and execute the run function on them, which only prints the thread number. Am I missing something? Is there any…
x89
  • 2,798
  • 5
  • 46
  • 110
-1
votes
1 answer

How to use scanf in a loop, store the value into one variable and then print it later?

I'm trying to make a program where user is able to input the number of test cases they want, input the number of alphabet, and then print it. Since I want to do the printf of the Cases after the value of i is the same as input, which means I have to…
WOTA
  • 5
  • 3
-1
votes
4 answers

How to find the length of a line in a text file?

I'm begginer in programming and I can't figure how to find length of line in text file in C language. I have text file where are names and numbers, every name and number is on different line and when I need to print it in output I need to have name…
-1
votes
1 answer

Print the structure values in c

I wrote a small program in c programming language. The program just get students data and save them in the struct fields. After that I was hoping to print the data but it seems that the code is not working properly. I wrote that in the visual studio…
HiDD3N
  • 29
  • 2
  • 7
-1
votes
1 answer

what code i use to ask the Quantity and Payment?

I think the problem starts before the nested if switch because at the end of the code it should output the result of sales = quantity * price and change = payment - total amount and asking quantity and Payment #include main() { int…
laura
  • 19
  • 5