

{"id":120724,"date":"2023-11-15T18:00:57","date_gmt":"2023-11-15T12:30:57","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=120724"},"modified":"2023-11-15T18:39:12","modified_gmt":"2023-11-15T13:09:12","slug":"c-string-functions","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/c-string-functions\/","title":{"rendered":"C String Functions with Examples"},"content":{"rendered":"<p>One of the most frequently used data types in all computer languages is the string. Strings are described in C as arrays of characters that end in the null character &#8220;0.&#8221; Writing C programs that store, manipulate, or communicate textual data requires proper string handling.<\/p>\n<h2>Explanation of Strings in C<\/h2>\n<p>Strings are kept in C as arrays of the char data type. A string&#8217;s characters each take up one byte of memory. The string&#8217;s final character is always the null terminator &#8216;0&#8217; to indicate the string&#8217;s end. <strong>For instance:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[6] = {'H','e','l','l','o','\\0'};<\/pre>\n<p>Here, str is an array of 6 characters, including the null terminator. The length of this string is 5 (excluding null).<\/p>\n<p><strong>We can also declare strings like this:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[6] = \"Hello\";<\/pre>\n<p>The compiler automatically appends the &#8216;\\0&#8217; at the end.<\/p>\n<p>Strings in C can be initialized but cannot be assigned. <strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">str = \"World\"; \/\/ Error<\/pre>\n<p>This is because arrays cannot be assigned in C. We need to use string functions like strcpy() for assignments.<\/p>\n<h3>Importance of String Handling in C<\/h3>\n<ul>\n<li>Textual data is very common in applications &#8211; names, addresses, messages, etc. Proper string handling helps manage this data efficiently.<\/li>\n<li>Strings are used for file I\/O, network communication, user interaction, data processing, etc., in C. Robust string functions help implement the core functionality.<\/li>\n<li>Strings in C are stored in simple character arrays. String functions in C are needed for manipulation like concatenation, substring search, case change, etc.<\/li>\n<li>Safety and security of string operations are also important to avoid bugs like buffer overflows. Secure string functions prevent vulnerabilities.<\/li>\n<li>Efficiency in string operations affects overall program performance. Optimized string functions improve speed for string-intensive applications.<\/li>\n<\/ul>\n<h3>Basic String Functions in C<\/h3>\n<p>C provides a wide range of built-in functions for manipulating strings. Here are some commonly used basic string functions.<\/p>\n<table style=\"height: 773px\" width=\"721\">\n<tbody>\n<tr>\n<td><b>Function<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strlen(string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Calculates and gives back the number of characters in the provided string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcpy(destination, source)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Takes the contents of the source string and puts them into the destination string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcat(first_string, second_string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Joins first_string and second_string together. The combined string is put into first_string.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcmp(first_string, second_string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Evaluate first_string and second_string to check if they are the same. Returns 0 if they match exactly.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strrev(string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Flips the order of the characters in the string and gives back the reversed version<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strlwr(string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Alters the string so all characters are in lowercase, then returns the lowercase string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strupr(string)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Alters the string so all characters are in uppercase, then returns the uppercase string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strlen()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns back the length of the provided string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strnlen()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Gives back the length specified if it is less than the string length; otherwise, it gives the full string length<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcmp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Assesses two strings and returns 0 if they match exactly<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strncmp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares only the first n characters of the two strings<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Joins two strings together and returns the combined string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strncat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Joins the first n characters of one string onto the end of another string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcpy()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Copies the contents of one string into a different string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strncpy()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Copies only the first n characters from one string into another string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strchr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds the first instance of a given character within a string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strrchr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds the last instance of a given character within a string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strstr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds the first instance of a given substring within a string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strnstr()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds the first instance of a given substring in a string, searching only the first n characters<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcasecmp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares two strings, ignoring the difference in capitalization<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strncasecmp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares only the first n characters of two strings, ignoring differences in capitalization<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>strlen() &#8211; Finding String Length<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">size_t strlen(const char *str);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>strlen() calculates the length of the given null-terminated string str.<\/li>\n<li>It returns the number of characters in the string excluding the null terminator &#8216;\\0&#8217;.<\/li>\n<li>This function is defined in string.h header file.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n  char str[50] = \"Hello, World!\";\r\n\r\n  int len = strlen(str);\r\n\r\n  printf(\"Length of the string is: %d\", len);\r\n  \r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Length of the string is: 13<\/div>\n<h4>strcpy() &#8211; Copying Strings<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *strcpy(char *destination, const char *source);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>Using the strcpy() function, you can copy a string from the source to the destination character array.<\/li>\n<li>It returns the destination string.<\/li>\n<li>Both strings should have enough space to store the content.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n  \r\n  char source[20] = \"Hello\";\r\n  char destination[20];\r\n\r\n  \/\/ Copies source to destination\r\n  strcpy(destination, source);\r\n\r\n  printf(\"Destination string: %s\", destination);\r\n\r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Destination string: Hello<\/div>\n<h4>strcat() &#8211; Concatenating Strings<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *strcat(char *destination, const char *source);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>You can copy a string from the source to the target character array using the strcpy() function.<\/li>\n<li>To save the combined text after concatenation, the destination string must have enough room.<\/li>\n<li>It returns the destination string.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char destination[30] = \"Hello\";\r\n  char source[15] = \"World\";\r\n\r\n  \/\/ Concatenates source to destination\r\n  strcat(destination, source);\r\n\r\n  printf(\"Destination string: %s\", destination);\r\n\r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Destination string: HelloWorld<\/div>\n<h4>strcmp() &#8211; Comparing Strings<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int strcmp(const char *str1, const char *str2);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>strcmp() compares two null-terminated strings lexicographically.<\/li>\n<li>If both strings are equal, it returns 0.<\/li>\n<li>Returns a negative number if str1 is less than str2.<\/li>\n<li>Returns a positive number if str1 is greater than str2.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str1[15];\r\n  char str2[15];\r\n  \r\n  strcpy(str1, \"Apple\");\r\n  strcpy(str2, \"Mango\");\r\n\r\n  int result = strcmp(str1, str2);\r\n  \r\n  if(result == 0) {\r\n    printf(\"Strings are equal\");\r\n  } else if(result &gt; 0) {\r\n    printf(\"str1 is greater than str2\"); \r\n  } else {\r\n    printf(\"str1 is less than str2\");\r\n  }\r\n  \r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> str1 is less than str2<\/div>\n<h3>Additional String Functions in C<\/h3>\n<p>Here are some more useful string functions provided in C.<\/p>\n<h4>strchr() &#8211; Finding a Character in a String<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *strchr(const char *str, int character);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>strchr() searches for the first occurrence of the given character in the string.<\/li>\n<li>It returns a pointer to the matched character in the string.<\/li>\n<li>If the character is not found, it returns NULL.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[50] = \"Hello, World!\";\r\n  char *result;\r\n\r\n  result = strchr(str, 'W');\r\n  \r\n  if(result) {\r\n    printf(\"Character found at %ld\", result-str);\r\n  } else {\r\n    printf(\"Character not found\");\r\n  }\r\n\r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Character found at 7<\/div>\n<h4>strstr() &#8211; Finding a Substring in a String<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *strstr(const char *str, const char *substr);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>strstr() searches for the first occurrence of substring substr in the string str.<\/li>\n<li>It returns a pointer to the beginning of the substring if found.<\/li>\n<li>If substr is not found, it returns NULL.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[100] = \"Hello, World!\";\r\n  char *result;\r\n  \r\n  result = strstr(str, \"World\");\r\n  \r\n  if(result) {\r\n    printf(\"Substring found at %ld\", result-str); \r\n  } else {\r\n    printf(\"Substring not found\");\r\n  }\r\n  \r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\">\n<p><strong>Output:<\/strong> Substring found at 7<\/p>\n<div>\n<h4>strtok() &#8211; Tokenizing Strings<\/h4>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *strtok(char *str, const char *delimiter);<\/pre>\n<p><strong>Purpose and Description<\/strong><\/p>\n<ul>\n<li>strtok() breaks the given string into tokens separated by the delimiter character(s).<\/li>\n<li>In the first call, it expects the string argument str. In subsequent calls, use NULL for str.<\/li>\n<li>It returns a pointer to the next token in the string.<\/li>\n<li>When no token is left, it returns NULL.<\/li>\n<\/ul>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[100] = \"Hello, This is a test\";\r\n  char *token;\r\n\r\n  \/\/ First call\r\n  token = strtok(str, \" \"); \r\n  while(token != NULL) {\r\n    printf(\"%s\\n\", token);\r\n    \r\n    \/\/ Subsequent calls\r\n    token = strtok(NULL, \" \"); \r\n  }\r\n  \r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong><\/div>\n<p>Hello,<br \/>\nThis<br \/>\nis<br \/>\na<br \/>\ntest<\/p>\n<h4>puts() and gets() &#8211; Input and Output Functions<\/h4>\n<p><strong>Syntax and Purpose<\/strong><\/p>\n<p><strong>puts() &#8211;<\/strong> Outputs a string to stdout and appends a new line.<br \/>\n<strong>gets() &#8211;<\/strong> Reads a string from stdin till newline.<\/p>\n<p><strong>Example for puts()<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[] = \"Hello, World!\";\r\n  \r\n  puts(str);\r\n  \r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong><\/div>\n<p>Hello, World!<\/p>\n<p><strong>Example for gets()<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[100];\r\n\r\n  printf(\"Enter a string: \");\r\n  gets(str);\r\n\r\n  printf(\"You entered: %s\", str);\r\n  \r\n  return 0;\r\n}<\/pre>\n<p><strong>Input:<\/strong> Hello, World!<\/p>\n<div class=\"df-code-out\"><strong>Output:<\/strong> You entered: Hello, World!<\/div>\n<h4>strlwr() \/ strupr() &#8211; Convert Strings to Lowercase \/ Uppercase<\/h4>\n<p><strong>Syntax and Purpose<\/strong><\/p>\n<p>strlwr() converts a string to lowercase.<br \/>\nstrupr() converts a string to uppercase<\/p>\n<p><strong>Example for strlwr()<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[20] = \"Hello WORLD\"; \r\n  strlwr(str);\r\n  \r\n  printf(\"Lowercase string: %s\", str);\r\n\r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Lowercase string: hello world<\/div>\n<p><strong>Example for strupr()<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[20] = \"Hello world\";\r\n  strupr(str);\r\n\r\n  printf(\"Uppercase string: %s\", str);\r\n\r\n  return 0;  \r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Uppercase string: HELLO WORLD<\/div>\n<h4>strrev() &#8211; Reverse a String<\/h4>\n<p><strong>Syntax and Purpose<\/strong><\/p>\n<p>strrev() reverses the given null-terminated string.<\/p>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main() {\r\n\r\n  char str[50] = \"Hello, World!\";\r\n\r\n  strrev(str);\r\n  \r\n  printf(\"Reversed string: %s\", str);\r\n\r\n  return 0;\r\n}<\/pre>\n<div class=\"df-code-out\"><strong>Output:<\/strong> Reversed string: !dlroW ,olleH<\/div>\n<h3>Performance Considerations<\/h3>\n<p>Optimizing string operations can significantly improve program efficiency.<\/p>\n<h4>Optimizing String Operations<\/h4>\n<ul>\n<li>Use pointer notation instead of array notation wherever possible.<\/li>\n<li>Use stack allocation instead of dynamic allocation if string sizes are known.<\/li>\n<li>Use char arrays instead of printf() where feasible.<\/li>\n<li>Use strnxxx() functions instead of strxxx() to avoid buffer overflows.<\/li>\n<li>Use const pointers for strings that won&#8217;t change.<\/li>\n<\/ul>\n<h4>Memory Allocation Strategies<\/h4>\n<ul>\n<li>Allocate string buffer size dynamically where possible.<\/li>\n<li>Use optimal string size to avoid large unused buffers.<\/li>\n<li>Reuse already allocated buffers instead of allocating new ones.<\/li>\n<li>Free buffers promptly after use for better memory utilization.<\/li>\n<\/ul>\n<h3>Use Cases and Examples<\/h3>\n<p><strong>Here are some examples of string usage in real-world C programs:<\/strong><\/p>\n<ul>\n<li><strong>File I\/O &#8211;<\/strong> Reading data from files into character arrays, parsing filenames, paths etc.<\/li>\n<li><strong>Networking &#8211;<\/strong> Transmitting textual data over sockets, parsing URLs, and formatting network packets.<\/li>\n<li><strong>Databases &#8211;<\/strong> Storing, retrieving and filtering data from databases.<\/li>\n<li><strong>Web servers &#8211;<\/strong> Handling HTTP requests, and generating HTML or JSON output.<\/li>\n<li><strong>Command-line interfaces &#8211;<\/strong> Reading user input, printing formatted output to console.<\/li>\n<li><strong>Text editors &#8211;<\/strong> Managing entire documents in memory, searching and replacing.<\/li>\n<\/ul>\n<h3>Conclusion<\/h3>\n<p>String handling is essential in C for storing, processing and communicating text-based data. This article covered C&#8217;s string representation, standard string functions, advanced manipulation, multibyte strings, performance optimization, and real-world applications across domains. Robust string functions make C suitable for diverse text-processing tasks.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the most frequently used data types in all computer languages is the string. Strings are described in C as arrays of characters that end in the null character &#8220;0.&#8221; Writing C programs&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":120726,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19488],"tags":[23914,28357,28358,28359],"class_list":["post-120724","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-c-programming","tag-c-string-functions","tag-string-function-in-c","tag-string-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C String Functions with Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"C string function represents, standard string functions, advanced manipulation, multibyte strings, performance optimization.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/c-string-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C String Functions with Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"C string function represents, standard string functions, advanced manipulation, multibyte strings, performance optimization.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/c-string-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-15T12:30:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-15T13:09:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C String Functions with Examples - DataFlair","description":"C string function represents, standard string functions, advanced manipulation, multibyte strings, performance optimization.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/c-string-functions\/","og_locale":"en_US","og_type":"article","og_title":"C String Functions with Examples - DataFlair","og_description":"C string function represents, standard string functions, advanced manipulation, multibyte strings, performance optimization.","og_url":"https:\/\/data-flair.training\/blogs\/c-string-functions\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-11-15T12:30:57+00:00","article_modified_time":"2023-11-15T13:09:12+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"C String Functions with Examples","datePublished":"2023-11-15T12:30:57+00:00","dateModified":"2023-11-15T13:09:12+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/"},"wordCount":1302,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp","keywords":["c programming","c string functions","string function in c","string in c"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/c-string-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/","url":"https:\/\/data-flair.training\/blogs\/c-string-functions\/","name":"C String Functions with Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp","datePublished":"2023-11-15T12:30:57+00:00","dateModified":"2023-11-15T13:09:12+00:00","description":"C string function represents, standard string functions, advanced manipulation, multibyte strings, performance optimization.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/c-string-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-functions-in-c.webp","width":1200,"height":628,"caption":"string functions in c"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/c-string-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"C Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"C String Functions with Examples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=120724"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120724\/revisions"}],"predecessor-version":[{"id":125986,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120724\/revisions\/125986"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/120726"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=120724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=120724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=120724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}