C Foundation

What is C? C Compiler Installation C Extensions C Compiler C Interpreter C Program Structure

C Basics

C Keywords C Data Types C Identifiers C Variables C Constant C Escape Sequences C Constant and Volatile C Typecast

Operators

What is Operator C Comma Operator C Arithmetic Operators C Relational Operators C Logical Operators C Bitwise Operators C Conditional Operators C : : Operator C Operator Priority

Basic IO's

Basic IO's C Formatted Functions C Unformatted Functions C Common Functions

Control Statements

What is Control Statement C if Statement C if else Statement C Nested if Statement C Else if Statement C Break Statement C Continue Statement C Switch Statement C Goto Statement

Looping

What is Control Loop C for Loop C Nested for Loop C while Loop C Nested while Loop C do while Loop C Nested do while loop

Functions

What is Function C User Defined Functions C Recursion C Passing Parameters

Scope

Scope C Local Scope C Global Scope

Storage Classes

What is Storage Class C Auto C Extern C Static C Register

Array

What is Array C One Dimensional Array C Two Dimensional Array C Multi Dimensional Array C Arrays Of Strings

String

What is String C String Functions

Pointer

What is Pointer C Pointers Arithmetic C Pointer to Pointer C Pointers and Arrays C Pointers and Strings C Pointer to Functions Void Pointers Null Pointers C Null and Void Pointer

Structure

What is Structure C Struct within Struct C Array within Structure C Pointer to Structure C Structure and Function C Enum C Bitfield Structure C Type def

Union

What is Union

Files

What is File C read a file C write a file C File Handling C Error Handling C Low Level Disk I/O C Other file functions

Memory Allocation

What is Memory Allocation C Malloc() C Calloc() C Free() C Realloc() C Coreleft()

C Reference

All ASCII Code Basic C Questions

C Interview

C Interview Sets All Star Patterns All Number Patterns All Alphabet Patterns All Series Patterns
The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Unformatted Functions

Unformatted input and output functions are only work with character data type. Unformatted input and output functions do not require any format specifiers. Because they only work with character data type.

Character IO Functions

getchar() Function

The getchar() function reads character type data form the input. The getchar() function reads one character at a time till the user presses the enter key.

getchar() C Program

getchar.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
char c;
printf("Enter a character : ");
c = getchar();
printf("\nEntered character : %c ", c);
return 0;
}
  • Enter a character : y
  • Entered character : y

Note:

Here, getchar() reads the input from the user and display back to the user.

getch() Function

The getch() function reads the alphanumeric character input from the user. But, that the entered character will not be displayed.

getch() C Program

getch.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
printf("\nHello, press any alphanumeric character to exit ");
getch();
return 0;
}
  • Hello, press any alphanumeric character to exit

Note:

The above program will run until you press one of many alphanumeric characters. The key pressed by you will not be displayed.

getche() Function

getche() function reads the alphanumeric character from the user input. Here, character you entered will be echoed to the user until he/she presses any key.

getche() C Program

getche.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
printf("\nHello, press any alphanumeric character or symbol to exit \n ");
getche();
return 0;
}
  • Hello, press any alphanumeric character or symbol to exit
  • k

Note:

The above program will run until you press one of many alphanumeric characters. The key pressed by you will be echoed.

putchar() Function

putchar() function prints only one character at a time.

putchar() C Program

putchar.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
char c = 'K';
putchar(c);
return 0;
}
  • K

Note:

Here, variable c is assigned to a character 'K'. The variable c is displayed by the putchar(). Use Single quotation mark ' ' for a character.

putch() Function

The putch() function prints any alphanumeric character.

putch() C Program

putch.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
char c;
printf("Press any key to continue\n ");
c = getch();
printf("input : ");
putch(c);
return 0;
}
  • Press any key to continue
  • input : d

Note:

The getch() function will not echo a character. The putch() function displays the input you pressed.

String IO Functions

gets() Function

The gets() function can read a full string even blank spaces presents in a string. But, the scanf() function leave a string after blank space space is detected. The gets() function is used to get any string from the user.

gets() C Program

gets.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
char c[25];
printf("Enter a string : ");
gets(c);
printf("\n%s is awesome ",c);
return 0;
}
  • Enter a string : Randy Orton
  • Randy Orton is awesome

Note:

The gets() function reads a string from through keyboard and stores it in character array c[25]. The printf() function displays a string on the console.

puts() Function

The puts() function prints the charater array or string on the console. The puts() function is similar to printf() function, but we cannot print other than characters using puts() function.

puts() C Program

puts.c
#include <stdio.h> //header file section
#include <conio.h>
int main()
{
char c[25];
printf("Enter your Name : ");
gets(c);
puts(c);
return 0;
}
  • Enter your Name: john
  • john

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report