- Input means to provide the program with some data to be used in the program
- Output means to display data on screen or write the data to a printer or a file.
- C programming language provides many built-in functions to read any given input and to display data on screen when there is a need to output the result.
- In this tutorial, we will learn about such functions, which can be used in our program to take input from user and to output the result on screen.
- All these built-in functions are present in C header file "#include<stdio.h>"
- To use the built in functions we have to specify header files at head in which a particular function is defined(written) while discussing about it.
Strings I/O
gets() & puts()
gets() Function:
- When you have to take input of more than One character then this function is Used.
- This Function is used to take input of Bunch of character
which is called as string.
Syntax:
gets(variable_name);
Example:
#include<stdio.h> //header file void main() { char b[10]; //this a string declaration,which will see further. gets(b); }
puts() Function:
- When you have to print of more than One character then this function is Used.
- This Function is used to print of Bunch of character
which is called as string.
Syntax:
puts(variable_name);
Example:
#include<stdio.h> //header file void main() { char b[10]; gets(b); //we took string as input. puts(b); //printing the string. }
Output
Hello world
Example2:
#include<stdio.h>
void main()
{
char s[10];
printf("Enter any string:");
gets(s);
puts(s);
}
#include<stdio.h> void main() { char s[10]; printf("Enter any string:"); gets(s); puts(s); }
Output:
Enter any string: Programmers are great
Programmers are great.
Further Concepts:
- 2D Strings
- Concept of 2D Strings
- What is Character array
- what are various string handling functions
- Functions for Characters
- Functions from #include<string.h> Header File
- what are strcpy(), strcmp(), strncmp(), strcmpi(),etc
- strcmp() VS strncmp() VS strcmpi()
- Functions from #include<ctype.h> Header File
- what are isdigit(), islower() , isupper(),etc
- Various Practice Programs on strings
Further Topics:
- Functions In C
- Why Functions?
- What are Functions?
- how to write our functions?
- What are programmer define functions?
- How to declare function?
- How to define a function?
- What is function Prototype?
- how to declare a function?
- what are Actual Parameters?
- What are Formal Parameters?
- Function Call?
- how to call a Function?
- What are different types of calling function?
- Call by value
- call by reference
- Recursion
- Array and Functions
- How to pass an array to a function?
- Practice programs
0 Comments
Post a Comment