String Handling and Manipulation in C: Functions and Examples, Slides of Computer Programming

An introduction to string handling and manipulation in c programming language. It covers various functions such as isdigit(), isalpha(), isalnum(), islower(), isupper(), tolower(), toupper(), isspace(), iscntrl(), ispunct(), isprint(), isgraph(), atof(), atoi(), atol(), strcpy(), strncpy(), strcmp(), strncmp(), strcat(), strncat(), strlen(), strchr(), strcspn(), strspn(), strpbrk(), strrchr(), and strstr(). The document also includes examples of using these functions.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

somo
somo 🇮🇳

4.8

(4)

70 documents

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Programming
Lecture 17
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download String Handling and Manipulation in C: Functions and Examples and more Slides Computer Programming in PDF only on Docsity!

Introduction to Programming

Lecture 17

String Handling

Character

ASCII

Example 1

#include<iostream.h>

main ( )

int i ;
char c ;
for( i = 0; i < 256 ; i ++ )
c = i ;
cout << i << “\t” << c <<endl ;

ctype Functions int isdigit ( int c ) int isalpha ( int c ) int isalnum ( int c ) int isxdigit ( int c ) int islower ( int c ) int isupper ( int c ) int tolower ( int c ) int toupper ( int c ) int isspace ( int c ) int iscntrl ( int c ) int ispunct ( int c ) int isprint ( int c ) int isgraph ( int c )

isalpha ( ) Function int isalpha ( int c ) ;

isalnum ( ) Function int isalnum ( int c ) ;

isupper ( ) Function int isupper ( int c ) ;

tolower ( ) Function int tolower ( int c ) ;

getchar ( ) ;

cout << “Please enter a character string then press enter”; while ( ( c = getchar ( ) ) != ‘\n’ ) { if ( islower ( c ) ) lc ++ ; else if ( isupper ( c ) ) uc ++ ; else if (isdigit ( c ) ) dig ++; else if ( isspace ( c ) ) ws ++ ; else if ( ispunct ( c ) ) pun ++ ; else oth ++ ; }

atoi ( ) Function char str [ ] ; int age ; age = atoi ( str ) ;

atof ( ) Function