W e b t u t o r i a l s

Programing Approach

Algorithm, Flow Chart

Define C

Define Programming

C - Syntax

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

Control Structure

Control Structure - if

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Constant Variable

C - Escape Sequence

C - Arrays 1D, 2D

C - Sorting

ASCII Value

Character I/O Function

C - Strings

Ex: Strings

Array of Strings

C - Math Functions

C - Functions

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

Typedef File Handling

Command Line Argument

MCQ

String in C

String is a collection of characters or String is an array of character which is terminated by a null character '\0'.


gets() - is use for input a string.
scanf("%[^\n]s", variable-name);

String functions in string.h header file.
S.no Functions Syntax Description
1. strlen l=strlen(a); Calculate length of String and store in integer variable.
2. strrev strrev(a); Reverse the string.
3. strupr strupr(a); Convert string into capital letters.
4. strlwr strlwr(a); Convert string into smaller letters.
5. strcpy strcpy(b,a); Copy contents of a into b.
6. strcat strcat(b,a); Append contents of one string into another.
7. strcmp l=strcmp(a,b); Compare two strings and return a integer value. Value is one of the following:
a. Less than 0 if b is greater
b. Greater than 0 if a is greater
c. Equal to 0 if both are equal
8. strcmpi or stricmp len=strcmpi(a,b); Compare 2 strings same as strcmp but it will ignore cases.
9. strncmp strncmp(b,a,n); Compare two Strings but only 1st n specified characters
10. strncpy strncpy(b,a,n); Copy only n specified characters, where n is a integer number.
11. strncat strncat(b,a,n); Concatenate only n specified characters.
12. strncmpi strncmpi(b,a,n); Compare two Strings but only 1st n specified characters and ignore cases.

Exercise questions on String

  1. Input String and find its length.
  2. Input String and reverse it.
  3. Input string and convert it into capital letters.
  4. Input string and convert it into small letters.
  5. Input string and copy into another variable.
  6. Input string and concatenate it.
  7. Input 2 strings and find both strings or not, if not, which string is greater.
  8. Compare 2 strings but ignore cases.
  9. Compare 2 strings but only n specified characters.