{"id":1412,"date":"2013-10-09T14:46:31","date_gmt":"2013-10-09T14:46:31","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=1412"},"modified":"2014-09-26T15:05:13","modified_gmt":"2014-09-26T15:05:13","slug":"c-basic-string-functions","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/strings\/c-basic-string-functions","title":{"rendered":"C++ Basic String Functions"},"content":{"rendered":"<p>\n&nbsp;\n<\/p>\n<pre>\r\n<code>\r\n#include &lt;string.h&gt;\r\n<\/code><\/pre>\n<h4>\nstrcpy &#8211; Copy string into string<br \/>\n<\/h4>\n<p>\nstrcpy(s1, s2);\n<\/p>\n<p>\nCopies string s2 into string s1.\n<\/p>\n<h4>\nstrcat&nbsp;&#8211; Add string to end of string<br \/>\n<\/h4>\n<p>\nstrcat(s1, s2);\n<\/p>\n<p>\nConcatenates string s2 onto the end of string s1.\n<\/p>\n<h4>\nstrlen &#8211; Get string length<br \/>\n<\/h4>\n<p>\nstrlen(s1);\n<\/p>\n<p>\nReturns the length of string s1.\n<\/p>\n<h4>\nstrcmp &#8211; Compare strings<br \/>\n<\/h4>\n<p>\nstrcmp(s1, s2);\n<\/p>\n<p>\nReturns 0 if s1 and s2 are the same; less than 0 if s1&lt;s2; greater than 0 if s1&gt;s2.\n<\/p>\n<h4>\nstrchr &#8211; Find character in string<br \/>\n<\/h4>\n<p>\nstrchr(s1, ch);\n<\/p>\n<p>\nReturns a pointer to the first occurrence of character ch in string s1.\n<\/p>\n<h4>\nstrstr &#8211; Find String in string<br \/>\n<\/h4>\n<p>\nstrstr(s1, s2);\n<\/p>\n<p>\nReturns a pointer to the first occurrence of string s2 in string s1.\n<\/p>\n<h4>\nExamples<br \/>\n<\/h4>\n<h5>\nCreating A String<br \/>\n<\/h5>\n<pre>\r\n<code>\r\n\tchar StatusString[255];\r\n\tstrcpy(StatusString, &quot;&lt;span font_desc=\\&quot;Arial 16\\&quot;&gt;Hello&quot;);\r\n\tstrcat(StatusString, &quot; World\\n&quot;);\r\n\tstrcat(StatusString, &quot;&lt;\/span&gt;&quot;);\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; #include &lt;string.h&gt; strcpy &#8211; Copy string into string strcpy(s1, s2); Copies string s2 into string s1. strcat&nbsp;&#8211; Add string to end of string strcat(s1, s2); Concatenates string s2 onto the end of string s1. strlen &#8211; Get string length strlen(s1); Returns the length of string s1. strcmp &#8211; Compare strings strcmp(s1, s2); Returns 0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-1412","post","type-post","status-publish","format-standard","hentry","category-strings"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":6,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1412\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1412\/revisions\/1707"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=1412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=1412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}