C/C++ Coding Exercise – Tiny Echo Program


The echo always responses the same text as input until you terminates it by Ctrl+C or Ctrl+Z (End of Line). This is more useful than “Hello, World” in the category of “First Program”.

1
2
3
4
5
6
7
#include <stdio.h>
 
void main() {
        int r;
        while ((r = fgetc(stdin)) >= 0)
                fputc((char)r, stdout);
}
#include <stdio.h>

void main() {
        int r;
        while ((r = fgetc(stdin)) >= 0)
                fputc((char)r, stdout);
}
cplusplus-echo C/C++ Coding Exercise - Tiny Echo Program beginner c / c++ programming languages

Echo Program in C/C++

The Ctrl+Z will input the End-of-Line so the program knows nothing further more to read.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
170 words
Last Post: How to Obtain the Second Distinct Highest Record using SQL?
Next Post: How to Capture Command Output from VBScript at Window Scripting Host?

The Permanent URL is: C/C++ Coding Exercise – Tiny Echo Program

Leave a Reply