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
-4
votes
2 answers

K&R exercise 1-23

I have two questions related to the titular exercise, from The C Programming Language. I'm sure that they've both been answered before, so either a direct answer or a link to a previous post (I couldn't find any) would be appreciated. The exercise…
-4
votes
2 answers

Loop statement problems

At the end of my program I want to ask the user if he wants to exit or not. PROBLEM: I want to create a loop, that would send the user to beginning (Point A) if he enters n or N, or to the end of my program (Point C) if he enters y or Y, or to the…
BeucaN
  • 3
  • 4
-5
votes
1 answer

is there a way to overwrite the variable in the code below

#include #include int main(){ float a,b,z,u,r,k; char f,q,m; system("color B"); repeat: printf("Unesite broj a: "); scanf("%f",&a); repeatm: printf("Unesite broj b: "); scanf("%f",&b); …
Tim Pavic
  • 13
  • 2
-5
votes
3 answers

Reading and Writing in C

so I was messing with the read functions fgets and scanf and with the printing functions write and printf with the following code: #include #include int main(int argc,char *argv[]) { printf("Enter an integer: "); int n…
magalenyo
  • 275
  • 6
  • 17
-5
votes
1 answer

Is runtime interpreter really part of C program execution?

As we know that C is a compiled language. According to C language Wikipedia it says that: It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map…
Destructor
  • 14,123
  • 11
  • 61
  • 126
-6
votes
1 answer

How can I generate a random number in C

I want to generate a random number/character without using any libraries but . Is there any possibility to do that? I mean, by doing some weird loop or something like that, I don't care, I just want to generate random stuff with the basic…
reshi
  • 1
-6
votes
2 answers

How to work with a variable number of variables in C?

So I was pondering about this problem in C using only stdio.h - I have to write a program that reads an integer p and then reads p integers. Now I have to use these p integers and perform another operation on them to get a final answer, which my…
Gravemind
  • 15
  • 3
-6
votes
2 answers

a is a double, printf("%d", a); works differently in IA32 and IA32-64

Why does The following code work totally differently on IA-32 and x86-64? #include int main() { double a = 10; printf("a = %d\n", a); return 0; } On IA-32, the result is always 0. However, on x86-64 the result…
Martin Gao
  • 61
  • 4
-6
votes
9 answers

' ', '\n' , scanf() and output screen

I wrote the following code to accept characters from user and enter into an array till he inputs a free space (' ') or a line \n. But code is not functioning. As in, when space bar or return key is pressed in the input, my computer is still…
Hari
  • 121
  • 1
  • 18
-9
votes
3 answers

Making function same as strlen() in C with only #include (no other header)

I'm going to have a test in next week. And in the sheet they say that "You can't use strlen() in test" How can I make it. Can use only ONLY!!!
chivacalo
  • 1
  • 1
1 2 3
72
73