

{"id":120720,"date":"2023-11-24T18:00:23","date_gmt":"2023-11-24T12:30:23","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=120720"},"modified":"2023-11-24T18:09:50","modified_gmt":"2023-11-24T12:39:50","slug":"strings-in-c","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/strings-in-c\/","title":{"rendered":"Strings in C with Examples"},"content":{"rendered":"<p>Strings are one of the most fundamental data types in programming. Though C does not have a dedicated string data type, we can represent strings using character arrays. String manipulation forms an essential part of most C programs. The use of strings in C programming, including how to define, initialise, modify, input, and output strings, will be covered in this article.<\/p>\n<h2>Character Arrays vs. Strings in C<\/h2>\n<p>In C, strings are actually one-dimensional character arrays terminated with a null character &#8216;\\0&#8217;. <strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char myString[6] = {'H', 'e', 'l', 'l', 'o', '\\0'};<\/pre>\n<p>Here, myString is a character array that can hold 6 characters. The last element \\0 is the null terminating character that marks the end of the string.<\/p>\n<p><strong>On the other hand, a regular character array does not need to be null terminated:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char chars[5] = {'a', 'b', 'c', 'd', 'e'};<\/pre>\n<p><strong>So, in summary, the main differences between a character array and a string in C are:<\/strong><\/p>\n<ul>\n<li>The null character, &#8220;0,&#8221; is appended internally by the compiler in the case of a character array, but we must add it ourselves to the end of the array in this case.<\/li>\n<li>The characters of the array can be changed, unlike the string literal, which cannot be changed to another set of characters.<\/li>\n<\/ul>\n<h3>Declaring and Initializing C Strings<\/h3>\n<p><strong>To declare a string in C, you specify the number of characters it can hold along with the char keyword:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char myString[100]; \/\/ can hold up to 99 chars + '\\0'<\/pre>\n<p><strong>To initialize a string, you can assign a string literal enclosed in double quotes:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char myString[6] = \"Hello\"; \/\/ ['H','e','l','l','o','\\0']<\/pre>\n<p>Note the use of double quotes which indicates a string literal, and the &#8216;\\0&#8217; null character automatically appended.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/declaring-and-initializing-string-in-c.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120794 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/declaring-and-initializing-string-in-c.webp\" alt=\"declaring and initializing string in c\" width=\"600\" height=\"400\" \/><\/a><\/p>\n<h3>Ways to Initialize a String in C<\/h3>\n<p><strong>There are several ways to initialize strings in C:<\/strong><\/p>\n<h4>1) Assigning a String Literal Without Size<\/h4>\n<p><strong>When we assign a string literal without specifying a size like:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[] = \"Hello\";<\/pre>\n<p>C automatically calculates the size of the string literal &#8220;Hello&#8221;, including the null terminator \\0. So it allocates a char array of size 6 to store the string.<\/p>\n<p>The advantage of this method is that we don&#8217;t have to manually specify any size. C takes care of memory allocation based on the literal.<\/p>\n<p>The disadvantage is that we cannot resize the array later since the size is fixed at initialization.<\/p>\n<h4>2) Assigning a String Literal With Size<\/h4>\n<p><strong>When we specify a size like:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[50] = \"Hello\";<\/pre>\n<p>Here, C will allocate a char array of size 50, initialize it with the literal &#8220;Hello&#8221;, and pad the remaining space with null terminators \\0.<\/p>\n<p>The advantage is that we can accommodate future string size increases up to the allocated memory.<\/p>\n<p>The disadvantage is that excess memory may get allocated if we specify a very large size.<\/p>\n<h4>3) Character By Character Initialization With Size<\/h4>\n<p><strong>When initializing character by character, we specify sizes like:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[6]; \r\nstr[0] = 'H';\r\nstr[1] = 'e'; \r\n...\r\nstr[5] = '\\0';<\/pre>\n<p>Here, we have full control over each character inserted into the array. But it involves more work manually inserting each character.<\/p>\n<p>The size helps prevent accidental buffer overflows by limiting writes beyond the array size. But strings without null terminators can cause issues.<\/p>\n<h4>4) Character By Character Initialization Without Size<\/h4>\n<p><strong>We can also initialize strings character by character without specifying size:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[] = {'H','e','l','l','o','\\0'};<\/pre>\n<p>C automatically allocates the size to hold the initialized characters plus the null terminator.<\/p>\n<p>This gives both flexibility of character by character initialization as well as safety of automatic memory allocation. But we lose the ability to resize arrays later.<\/p>\n<h3>String Examples<\/h3>\n<p><strong>Let&#8217;s look at some common programming examples related to strings in C:<\/strong><\/p>\n<h4>1. Printing Strings<\/h4>\n<p><strong>We can print strings normally with printf:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[] = \"Hello World\";\r\nprintf(\"%s\", str);<\/pre>\n<p><strong>Output:<\/strong><br \/>\nHello World<\/p>\n<p>To print strings, use the%s format specifier.<\/p>\n<h4>2. Reading String Input<\/h4>\n<p><strong>To read a string from user input:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[50];\r\nscanf(\"%s\", str);\r\nprintf(\"%s\", str);<\/pre>\n<p><strong>Input:<\/strong><br \/>\nDataFlair<\/p>\n<p><strong>Output:<\/strong><br \/>\nDataFlair<\/p>\n<h4>3. Reading Strings with Spaces<\/h4>\n<p><strong>scanf() stops at whitespace. To read strings with spaces:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[50];\r\nfgets(str, 50, stdin);\r\nputs(str);<\/pre>\n<p><strong>Input:<\/strong><br \/>\nDataFlair Tutorials<\/p>\n<p><strong>Output:<\/strong><br \/>\nDataFlair Tutorials<\/p>\n<p><strong>We can also use scanf() with scanset:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[20];\r\nscanf(\"%[^\\n]s\", str);\r\nprintf(\"%s\", str);<\/pre>\n<h4>4. Finding String Length<\/h4>\n<p><strong>Get string length with a loop:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char str[] = \"Hello\";\r\nint len = 0;\r\nwhile(str[len] != '\\0') {\r\n  len++; \r\n}\r\nprintf(\"Length is: %d\", len);<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Length is:<\/strong> 5<\/p>\n<p>Or use strlen() from string.h<\/p>\n<h4>5. Passing Strings to Functions<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void printStr(char str[]) {\r\n  printf(\"%s\", str); \r\n}\r\nint main() {\r\n  char str[] = \"DataFlair\";\r\n  printStr(str);\r\n  return 0;\r\n}<\/pre>\n<p><strong>Output:<\/strong><br \/>\nDataFlair<\/p>\n<p>So, in summary, strings in C can be used in various ways as illustrated by these examples. The key is choosing the right functions based on your specific string processing needs.<\/p>\n<h3>String.h Functions<\/h3>\n<table>\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(s)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Calculates the length of string s<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcpy(s1, s2)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Copies string s2 into string s1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcat(s1, s2)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Concatenates string s2 to end of string s1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strcmp(s1, s2)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares string s1 and s2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strchr(s,ch)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds first occurrence of char ch in string s<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strstr(s1, s2)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds first occurrence of string s2 in string s1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strlwr(s)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Converts string s to lowercase<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">strupr(s)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Converts string s to uppercase<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">memcpy(s1, s2, n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Copies n chars from string s2 to s1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">memmove(s1, s2, n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">Moves n chars from string s2 to s1<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\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 s1[10] = \"hello\";\r\n  char s2[10] = \"world\";\r\n  \r\n  \/\/ strlen()\r\n  int len = strlen(s1);\r\n  printf(\"Length of s1: %d\\n\", len);\r\n\r\n  \/\/ strcpy()  \r\n  strcpy(s2, s1);\r\n  printf(\"s2 after strcpy: %s\\n\", s2);\r\n\r\n  \/\/ strcat()\r\n  strcat(s1, s2);\r\n  printf(\"s1 after strcat: %s\\n\", s1);\r\n\r\n  \/\/ strcmp()\r\n  int result = strcmp(s1, s2);\r\n  if(result == 0) {\r\n    printf(\"s1 and s2 are equal\\n\");\r\n  } else {\r\n    printf(\"s1 and s2 are not equal\\n\");\r\n  }\r\n\r\n  \/\/ strlwr()\r\n  strlwr(s1);\r\n  printf(\"s1 after strlwr: %s\\n\", s1);\r\n\r\n  \/\/ strupr()\r\n  strupr(s1);\r\n  printf(\"s1 after strupr: %s\\n\", s1);\r\n  return 0;\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong>Length of s1:<\/strong> 5<br \/>\n<strong>s2 after strcpy:<\/strong> hello<br \/>\n<strong>s1 after strcat:<\/strong> hellohello<br \/>\ns1 and s2 are not equal<br \/>\n<strong>s1 after strlwr:<\/strong> hellohello<br \/>\n<strong>s1 after strupr:<\/strong> HELLOHELLO<\/p>\n<h3>Input and Output of Strings<\/h3>\n<p><strong>We can use scanf() and printf() for input and output of strings in C:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n  char name[50];\r\n\r\n  \/\/ Input string  \r\n  printf(\"Enter your name: \");\r\n  scanf(\"%s\", name); \/\/ %s format specifier \r\n  \r\n  printf(\"Hello %s!\", name);\r\n  \r\n  return 0;\r\n}<\/pre>\n<p><strong>Some points to note:<\/strong><\/p>\n<ul>\n<li>%s format specifier is used in scanf() and printf() to read and write strings.<\/li>\n<li>scanf() stops reading input at the first space, so it won&#8217;t read full strings containing spaces.<\/li>\n<li>To read strings with spaces, you can use fgets().<\/li>\n<\/ul>\n<h3>String Handling Best Practices<\/h3>\n<p><strong>When handling strings in C, some best practices include:<\/strong><\/p>\n<ul>\n<li>Always allocate sufficient memory to hold the string contents and null terminator.<\/li>\n<li>Use the length limiting modifiers like %49s in scanf() to avoid buffer overflow.<\/li>\n<li>Use strlen() to get string length before operations like concatenation.<\/li>\n<li>Use strcpy() and strcat() safely to avoid buffer overflows.<\/li>\n<li>Free dynamically allocated strings using free() to avoid memory leaks.<\/li>\n<li>Use const keyword for string literals to avoid accidentally modifying them.<\/li>\n<\/ul>\n<p>Following these practices will help avoid common pitfalls like buffer overflows and memory leaks.<\/p>\n<h3>Some important points<\/h3>\n<ul>\n<li>The character array&#8217;s limits are not checked by the compiler. As a result, there may be instances where a string&#8217;s length exceeds the character array&#8217;s size, overwriting some crucial information.<\/li>\n<li>We may utilise the built-in function gets(), which is defined in a header file string, instead of using scanf.h. Only one string can be passed to the gets() function at a time.<\/li>\n<\/ul>\n<h3>Strings and Pointers in C<\/h3>\n<p>In C, strings are closely linked to pointers. In fact, C treats string literals as constant character pointers. <strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char *ptr = \"Hello\";<\/pre>\n<p>Here ptr contains the address of the first character &#8216;H&#8217;. <strong>We can access each character using pointer arithmetic:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ptr[0]; \/\/ 'H' \r\nptr[1]; \/\/ 'e'<\/pre>\n<p><strong>Many string manipulation functions also take pointers as arguments rather than arrays:<\/strong><\/p>\n<h4>strlen(ptr); \/\/ ptr pointing to a string<\/h4>\n<p>So, pointers provide an efficient way to manipulate strings by directly accessing character data. Learning about pointers helps gain mastery over strings in C.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n    char phrase[] = \"Welcome to DataFlair Tutorials\";\r\n    char *ptr = phrase; \/\/ Pointer to the beginning of the string\r\n\r\n    printf(\"Original Phrase: %s\\n\", phrase);\r\n    \r\n    \/\/ Using a pointer to print the phrase character by character\r\n    printf(\"Phrase (using pointer): \");\r\n    while (*ptr != '\\0') {\r\n        printf(\"%c\", *ptr);\r\n        ptr++; \/\/ Move the pointer to the next character\r\n    }\r\n    printf(\"\\n\");\r\n\r\n    \/\/ Reset the pointer to the beginning of the phrase\r\n    ptr = phrase;\r\n\r\n    \/\/ Find and print the length of the phrase using a pointer\r\n    int length = 0;\r\n    while (*ptr != '\\0') {\r\n        length++;\r\n        ptr++;\r\n    }\r\n    printf(\"Phrase Length: %d\\n\", length);\r\n\r\n    return 0;\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong>Original Phrase:<\/strong> Welcome to DataFlair Tutorials<br \/>\n<strong>Phrase (using pointer):<\/strong> Welcome to DataFlair Tutorials<br \/>\nPhrase Length: 29<\/p>\n<h3>Conclusion<\/h3>\n<p>String manipulation forms a key part of C programming. In this article, we learned the basics of strings in C &#8211; declarations, initializations, input\/output, manipulation functions and relationship with pointers. C strings provide a lot of flexibility but also require some care to use safely and efficiently. With this foundation, you can confidently handle strings in your C applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Strings are one of the most fundamental data types in programming. Though C does not have a dedicated string data type, we can represent strings using character arrays. String manipulation forms an essential part&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":120722,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19488],"tags":[23914,29133,20333,28385,19933],"class_list":["post-120720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-c-programming","tag-c-tutorials","tag-c-strings","tag-declaring-and-initializing-strings-in-c","tag-strings-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Strings in C with Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"In this article, strings in C we learned declarations, initializations, input\/output, manipulation functions and relationship with pointers.\" \/>\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\/strings-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Strings in C with Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"In this article, strings in C we learned declarations, initializations, input\/output, manipulation functions and relationship with pointers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/strings-in-c\/\" \/>\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-24T12:30:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-24T12:39:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-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":"Strings in C with Examples - DataFlair","description":"In this article, strings in C we learned declarations, initializations, input\/output, manipulation functions and relationship with pointers.","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\/strings-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Strings in C with Examples - DataFlair","og_description":"In this article, strings in C we learned declarations, initializations, input\/output, manipulation functions and relationship with pointers.","og_url":"https:\/\/data-flair.training\/blogs\/strings-in-c\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-11-24T12:30:23+00:00","article_modified_time":"2023-11-24T12:39:50+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-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\/strings-in-c\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Strings in C with Examples","datePublished":"2023-11-24T12:30:23+00:00","dateModified":"2023-11-24T12:39:50+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/"},"wordCount":1181,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-in-c.webp","keywords":["c programming","c tutorials","C++ Strings","declaring and initializing strings in c","Strings in C"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/strings-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/","url":"https:\/\/data-flair.training\/blogs\/strings-in-c\/","name":"Strings in C with Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-in-c.webp","datePublished":"2023-11-24T12:30:23+00:00","dateModified":"2023-11-24T12:39:50+00:00","description":"In this article, strings in C we learned declarations, initializations, input\/output, manipulation functions and relationship with pointers.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/strings-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-in-c.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/string-in-c.webp","width":1200,"height":628,"caption":"string in c"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/strings-in-c\/#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":"Strings in C 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\/120720","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=120720"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120720\/revisions"}],"predecessor-version":[{"id":126897,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120720\/revisions\/126897"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/120722"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=120720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=120720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=120720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}