<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3AHTTB%3APointers%3AC_Strings</id>
	<title>SE250:HTTB:Pointers:C Strings - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3AHTTB%3APointers%3AC_Strings"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:HTTB:Pointers:C_Strings&amp;action=history"/>
	<updated>2026-04-28T14:58:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:HTTB:Pointers:C_Strings&amp;diff=1989&amp;oldid=prev</id>
		<title>Mark: 7 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:HTTB:Pointers:C_Strings&amp;diff=1989&amp;oldid=prev"/>
		<updated>2008-11-03T05:09:50Z</updated>

		<summary type="html">&lt;p&gt;7 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td bgcolor=&amp;quot;#552200&amp;quot; width=&amp;quot;1000&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;image src=&amp;quot;http://www.rajithaonline.com/SE250/httb/pointers/final/strings_head.png&amp;quot; width=&amp;quot;214&amp;quot; height=&amp;quot;92&amp;quot; alt=&amp;quot;Strings Header Logo&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SE250:HTTB:NAV&lt;br /&gt;
|prev=SE250:HTTB:Pointers:Arrays_and_pointers&lt;br /&gt;
|next=SE250:HTTB:Pointers:sizeof%2C_malloc_and_free}}&lt;br /&gt;
&lt;br /&gt;
=== C Strings ===&lt;br /&gt;
The &amp;lt;string.h&amp;gt; library gives many useful functions for manipulating string data(copy strings and concatenating strings), comparing strings, searching strings for characters and other strings, tokenizing string and determining the length of strings.  &lt;br /&gt;
&lt;br /&gt;
The functions include:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
char *strcpy(char *s1, char *s2)&lt;br /&gt;
    Copies string s2 into array s1. The value of s1 is returned.&lt;br /&gt;
 &lt;br /&gt;
char *strncpy(char *s1, char * s2, int n)&lt;br /&gt;
    Copies at most n characters from s2 into s1. The value of s1 is returned. &lt;br /&gt;
 &lt;br /&gt;
char *strcat(char *s1, char *s2)&lt;br /&gt;
    Appends string s2 to array s1. The first character of s2 overwrites the termination null&lt;br /&gt;
    character of s1. Value of s1 is returned&lt;br /&gt;
 &lt;br /&gt;
char *strncat(char *s1, char *s2, int n)&lt;br /&gt;
    Appends at most n characters from s2 to s1. First character from s2 overwrites the terminating null character of s1.&lt;br /&gt;
    The value of s1 is returned.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
String comparison methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int strcmp(char *s1, char *s2)&lt;br /&gt;
    Compares the string s1 with the string s2. The function returns 0, less than 0, or greater than 0&lt;br /&gt;
    if s1 is equal to, less than or greater than s2.&lt;br /&gt;
 &lt;br /&gt;
int strncmp(char *s1, char *s2, int n)&lt;br /&gt;
    Compares up to n characters of s1 with s2. Function returns 0, less than 0 or greater than&lt;br /&gt;
    0 if s1 is equal to, less than or greater than s2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
String search methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
char *strchr(char *s, char c)&lt;br /&gt;
    Find the first occurrence of character c in string s. Returns pointer to c in s if character is found.&lt;br /&gt;
 &lt;br /&gt;
char *strpbrk(char *s1, char *s2)&lt;br /&gt;
    Locates the first occurrence of string s1 of any character in string s2. If a character from s2 is found, pointer to that&lt;br /&gt;
    character is returned.&lt;br /&gt;
 &lt;br /&gt;
char *strrchr(char *s, char c)&lt;br /&gt;
    Locates the last occurrence of c in string s. If c is found, a pointer to c in string s is returned.&lt;br /&gt;
 &lt;br /&gt;
char *strstr(char *s1, char *s2)&lt;br /&gt;
    Locates the first occurrence in string s1 of string s2. If string is found, then a pointer to the string in s1 is returned.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====String Basics====&lt;br /&gt;
A string is a series of characters treated as a single unit, and can contain letters, digits and various special characters. String literals, or string constants are written in double quotation marks for C. &lt;br /&gt;
&lt;br /&gt;
String is an array of characters ending in the null character(&amp;#039;\0&amp;#039;), and is accessed via a pointer to the first character in the string. Therefore, a string is a pointer to the string&amp;#039;s first character.&lt;br /&gt;
&lt;br /&gt;
Definitions:&lt;br /&gt;
&lt;br /&gt;
 char colour[]= &amp;quot;black&amp;quot;;&lt;br /&gt;
 char *colour = &amp;quot;orange&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
String can be stored using the scanf function:&lt;br /&gt;
&lt;br /&gt;
 scanf(&amp;quot;%s&amp;quot;, word);&lt;br /&gt;
&lt;br /&gt;
Note that word is an array which is a pointer storing the word entered by the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{SE250:HTTB:NAV&lt;br /&gt;
|prev=SE250:HTTB:Pointers:Arrays_and_pointers&lt;br /&gt;
|next=SE250:HTTB:Pointers:sizeof%2C_malloc_and_free}}&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>