4. C_IOandProgramming_1101
4. C_IOandProgramming_1101
string.h:String functions
strcat() concatenates a copy of str2 to str1
strcmp() compares two strings
strcpy() copys contents of str2 to str1
Library Function with Header file
ctype.h: Character functions
isdigit() returns non-0 if arg is digit 0 to 9
isalpha() returns non-0 if arg is a letter of the alphabet
isalnum() returns non-0 if arg is a letter or digit
islower() returns non-0 if arg is lowercase letter
isupper() returns non-0 if arg is uppercase letter
stdlib.h:
Miscellaneous functions
malloc() provides dynamic memory allocation
rand() generates random numbers
srand() used to set the starting point for rand()
The scanf() & printf() functions
The C library function scanf() reads input from stdin.
The C library function printf() sends output to stdout..
The scanf() & printf() functions
examle2
The getchar() & putchar() functions
The getchar() function reads only single character at a time.
The putchar(c) function displays single character on the screen.
Programming example with getchar( ) and putchar()
char c;
printf( "Enter a value :");
c = getchar();
printf( "\nYou entered: ");
putchar(c);
The gets() & puts() functions
The gets() function reads a line of text .
The puts() function displays a line of text.
char str[100];
printf( "Enter a value :");
gets(str);
puts(str);
Thank You.
Questions and Answer
References
Books:
1. Programming With C. By Byron Gottfried
2. The Complete Reference C. By Herbert Shield
3. Programming in ANSI C By E. Balagurusamy
4. Teach yourself C. By Herbert Shield
Web:
1. www.wikbooks.org
and other slide, books and web search.