SlideShare a Scribd company logo
BY
B.ABINAYA BHARATHI M.Sc.,
NSCAS.
INTRODUCTION
Reading , processing and writing are the three main
functions in a program.
For reading and writing we are using two formatted I/O
function
* printf() -for writing
* scanf() -for reading
There are two types of I/O functions
* formatted I/O
* unformatted I/O
Formatted I/O
printf() ~ used to print output to the screen.
SYNTAX:
printf(“format”,var1,var2…);
format represent the text to be displayed or format
specification a or some escape sequence.
Ex: printf(“n A Value : %d “,a);
Escape sequence Text to be
displayed
Format
specification
variable
printf() never proceed in a newline automatically.
printf() also support special format specification.
General form:
%w.p type-specifier
w-total number of columns for a output value.
p-number of digits right side of the decimal.
Example:
printf(“%2d”,a); - for integer value.
printf(“%2.7f”,a); - for real value
printf(“%2c”,a); - for a character
printf(“%2s”,a); - for a string
Commonly used Type specifiers
scanf()- getting input from the user.
SYNTAX:
scanf(“format”,&var);
format represent the what type specifier ?
& represent the where the input to be stored.
var is a variable.
Ex: scanf(“%s”,&a);
Format specifier variable
Managing I/O & String function in C
Managing I/O & String function in C
UNFORMATTED I/O
getchar() - is used to read a single character.
General form:
var_name=getchar ();
putchar() – is used to write a character.
General form:
putchar(var_name);
Managing I/O & String function in C
Managing I/O & String function in C
To read and write a single character we are using
getchar() , putchar() , %c.
To read and write a string we normally use %s . Another
way is gets() and puts().
gets() - This function is used to get a string.
puts() - This function is used to print a string.
General Form:
gets(variable);
puts(variable);
(or)
puts(“sting to be displayed”);
Managing I/O & String function in C
Managing I/O & String function in C
STRING FUNCTIONS
In C there are predefined string functions or string
manipulation.
common string function
* strcat() – combine two strings
* strcmp() – compare two strings
* strcpy() – copy two strings
* strupr() – convert to uppercase
* strlen() – length of the string
* strlwr() – convert to lowercase
<string.h> header file is used to use these string functions.
SYNTAX:
strcat()
strcat(string1,string2);
strcmp()
strcmp(string1,string2);
strcpy()
strcpy(string1,string2);
strupr()
strupr(string1);
strlwr()
strlwr(string1);
strlen()
strlen(string1);
Managing I/O & String function in C
Managing I/O & String function in C
Other string functions
strncpy() - it copies the source string to the destination
string
SYNTAX:
strncpy( dest , source , n);
dest – where the content to be copied.
source – Thus is the string to be copied
n – number of character to be copied from the
source.
strncmp() - compares the first n bytes of string1 and
string2.
SYNTAX:
strncmp(string1,string2,n);
string1 – first string
string2 – second string
n - maximum number of characters to be
compared
strstr() – used to find the substring is present or not.
SYNTAX:
strstr(string1,string2);
strncat() - It is used to combine two strings. combine the
first n bytes of string1 and string2.
strncat(string1,string2,n);
string1 – first string
string2 – second string
n - maximum number of characters to be
combined.
Managing I/O & String function in C
Managing I/O & String function in C
THANK YOU

More Related Content

PDF
Managing I/O in c++
PDF
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Constructor and Types of Constructors
PPT
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
PDF
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
PDF
Friend function in c++
PPTX
Union in c language
PPTX
Branching statements
Managing I/O in c++
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
Constructor and Types of Constructors
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
Friend function in c++
Union in c language
Branching statements

What's hot (20)

PDF
C++ tokens and expressions
PPT
Strings Functions in C Programming
PDF
C Pointers
PPTX
Operators and expressions in c language
PDF
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Operators and expressions in C++
PPTX
sSCOPE RESOLUTION OPERATOR.pptx
PPTX
Lesson 4a - permutation matrices
PPTX
Function overloading
PPT
PPTX
Introduction to Array ppt
PPTX
Typedef
PDF
The solution manual of programming in ansi by Robin
PPTX
Programming in c Arrays
PPTX
C programing -Structure
PPTX
Structure in C language
PPTX
Functions in c language
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
PPT
pre processor directives in C
PPTX
Constructor in java
C++ tokens and expressions
Strings Functions in C Programming
C Pointers
Operators and expressions in c language
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
Operators and expressions in C++
sSCOPE RESOLUTION OPERATOR.pptx
Lesson 4a - permutation matrices
Function overloading
Introduction to Array ppt
Typedef
The solution manual of programming in ansi by Robin
Programming in c Arrays
C programing -Structure
Structure in C language
Functions in c language
Constants Variables Datatypes by Mrs. Sowmya Jyothi
pre processor directives in C
Constructor in java
Ad

Similar to Managing I/O & String function in C (20)

PPTX
Lecture_on_string_manipulation_functions.pptx
PPTX
Computer Programming Utilities the subject of BE first year students, and thi...
PPTX
Input Output function in c programing language.pptx
PDF
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Functions of stdio conio
PPTX
Managing input and output operation in c
PPTX
C programming(part 3)
PDF
String notes
PDF
String
PPT
Cfbcgdhfghdfhghggfhghghgfhgfhgfhhapter11.PPT
PPT
Chapterabcdefghijklmnopqrdstuvwxydanniipo
PPT
THE FORMAT AND USAGE OF STRINGS IN C.PPT
PPTX
Handling of character strings C programming
DOCX
Array &strings
PPTX
pps unit 3.pptx
PPT
CPU INPUT OUTPUT
PPTX
Input and Output In C Language
PPTX
Console I/o & basics of array and strings.pptx
PPT
Lecture 05 2017
PPTX
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
Lecture_on_string_manipulation_functions.pptx
Computer Programming Utilities the subject of BE first year students, and thi...
Input Output function in c programing language.pptx
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
Functions of stdio conio
Managing input and output operation in c
C programming(part 3)
String notes
String
Cfbcgdhfghdfhghggfhghghgfhgfhgfhhapter11.PPT
Chapterabcdefghijklmnopqrdstuvwxydanniipo
THE FORMAT AND USAGE OF STRINGS IN C.PPT
Handling of character strings C programming
Array &strings
pps unit 3.pptx
CPU INPUT OUTPUT
Input and Output In C Language
Console I/o & basics of array and strings.pptx
Lecture 05 2017
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
Ad

More from Abinaya B (18)

PPTX
Multimedia
PPTX
Overview of bigdata
PPTX
exception handling in java
PPTX
data structures
PPTX
graphics programming in java
PPTX
data structures- back tracking
PPTX
exception handling in java
PPTX
digital image processing
PPTX
Image filtering in Digital image processing
PPTX
software engineering
PPTX
software cost factor
PPTX
Data Mining
PPTX
Datamining
PPTX
Basic topic on os
PPTX
Digital principles basic
PPTX
Rdbms1
PPTX
Introduction to 80386
PPTX
Network standardization
Multimedia
Overview of bigdata
exception handling in java
data structures
graphics programming in java
data structures- back tracking
exception handling in java
digital image processing
Image filtering in Digital image processing
software engineering
software cost factor
Data Mining
Datamining
Basic topic on os
Digital principles basic
Rdbms1
Introduction to 80386
Network standardization

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PDF
Basic Mud Logging Guide for educational purpose
PDF
RMMM.pdf make it easy to upload and study
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Classroom Observation Tools for Teachers
Basic Mud Logging Guide for educational purpose
RMMM.pdf make it easy to upload and study
STATICS OF THE RIGID BODIES Hibbelers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Microbial disease of the cardiovascular and lymphatic systems
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Anesthesia in Laparoscopic Surgery in India
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pre independence Education in Inndia.pdf
Supply Chain Operations Speaking Notes -ICLT Program

Managing I/O & String function in C

  • 2. INTRODUCTION Reading , processing and writing are the three main functions in a program. For reading and writing we are using two formatted I/O function * printf() -for writing * scanf() -for reading There are two types of I/O functions * formatted I/O * unformatted I/O
  • 3. Formatted I/O printf() ~ used to print output to the screen. SYNTAX: printf(“format”,var1,var2…); format represent the text to be displayed or format specification a or some escape sequence. Ex: printf(“n A Value : %d “,a); Escape sequence Text to be displayed Format specification variable
  • 4. printf() never proceed in a newline automatically. printf() also support special format specification. General form: %w.p type-specifier w-total number of columns for a output value. p-number of digits right side of the decimal. Example: printf(“%2d”,a); - for integer value. printf(“%2.7f”,a); - for real value printf(“%2c”,a); - for a character printf(“%2s”,a); - for a string
  • 5. Commonly used Type specifiers
  • 6. scanf()- getting input from the user. SYNTAX: scanf(“format”,&var); format represent the what type specifier ? & represent the where the input to be stored. var is a variable. Ex: scanf(“%s”,&a); Format specifier variable
  • 9. UNFORMATTED I/O getchar() - is used to read a single character. General form: var_name=getchar (); putchar() – is used to write a character. General form: putchar(var_name);
  • 12. To read and write a single character we are using getchar() , putchar() , %c. To read and write a string we normally use %s . Another way is gets() and puts(). gets() - This function is used to get a string. puts() - This function is used to print a string. General Form: gets(variable); puts(variable); (or) puts(“sting to be displayed”);
  • 15. STRING FUNCTIONS In C there are predefined string functions or string manipulation. common string function * strcat() – combine two strings * strcmp() – compare two strings * strcpy() – copy two strings * strupr() – convert to uppercase * strlen() – length of the string * strlwr() – convert to lowercase <string.h> header file is used to use these string functions.
  • 19. Other string functions strncpy() - it copies the source string to the destination string SYNTAX: strncpy( dest , source , n); dest – where the content to be copied. source – Thus is the string to be copied n – number of character to be copied from the source.
  • 20. strncmp() - compares the first n bytes of string1 and string2. SYNTAX: strncmp(string1,string2,n); string1 – first string string2 – second string n - maximum number of characters to be compared strstr() – used to find the substring is present or not. SYNTAX: strstr(string1,string2);
  • 21. strncat() - It is used to combine two strings. combine the first n bytes of string1 and string2. strncat(string1,string2,n); string1 – first string string2 – second string n - maximum number of characters to be combined.