Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

08 May 2012

String Functions in 'C' (#include<stdio.h>)

The 'C' language provides a number of functions which help when handling strings.

strcat(string1, string2);

This function concatenates (adds to the end of) string2 to string1.
char string1[30] = "First String", string2[15] = "Second String";
strcat(string1, string2);
printf("%s", string1); // will print First StringSecond String
strlen(string);

Use of Strings in 'C'

A string is defined in 'C' as an array (list) of characters.

char str[10];   defines a string variable of 10 characters.

When data is placed in a string variable, a null character is placed at the end of the data. It is possible to look for this null when processing the string, so that processing