gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Pointers"},{"term":"string"},{"term":"Array"},{"term":"Learn C"},{"term":"Fundamental"},{"term":"Pattern"},{"term":"control sturctures"},{"term":"searching and sorting"},{"term":"recursion"},{"term":"List of C Programs"},{"term":"Structures"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Contents"},{"term":"Common Programming Error"},{"term":"functions"},{"term":"Dynamic memory allcation"}],"title":{"type":"text","$t":"C Programming Tutorial"},"subtitle":{"type":"html","$t":"It is a blog about c programming. Here we provide c programs and tutorials to enhance your skills."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/string?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/string?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"alternate","type":"text/html","href":"http://www.comp-psyche.com/search/label/string"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"6"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"50"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-2178441596240428818"},"published":{"$t":"2014-01-29T06:37:00.000-08:00"},"updated":{"$t":"2014-04-16T01:03:28.008-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : STRINGS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings4.html#21\" name\u003d\"21\"\u003e21. Program to accept a string and print each word of the string separately also print total number of words\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring, word\u003dto store the word\n char str[50], word[50];\n \n /* Declaring variable cw\u003dcount words, i\u003dto iterate loop, \n j\u003dworks as index position of word */\n int cw\u003d0, i, j\u003d0;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n /* We are concatinating a space here assuming user does not \n give space at the last */\n strcat(str,\" \");\n\n // Printing string\n printf(\"Entered string : %s\",str);\n \n //Determing total number of words and displaying it\n for(i\u003d0;str[i]!\u003d'\\0';i++)\n {\n  if(str[i]!\u003d' ')\n  {\n   word[j++]\u003dstr[i];\n  }\n  else\n  {\n   word[j]\u003d'\\0';\n   printf(\"\\nWord : %s\",word);\n   cw++;\n   j\u003d0;\n  }\n }\n \n // Printing total words\n printf(\"\\nTotal number of words : %d\",cw);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings4.html#22\" name\u003d\"22\"\u003e22. Program to accept a string and display vowels frequency( total number of vowels)\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n /* Declaring variable cv\u003dcount vowel, i\u003dto iterate loop \n ( i works as index position) */\n int cv\u003d0, i;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Checking if vowels and counting them\n for(i\u003d0;str[i]!\u003d'\\0';i++)\n {\n  if(str[i]\u003d\u003d'a' || str[i]\u003d\u003d'A' || str[i]\u003d\u003d'e' || str[i]\u003d\u003d'E' || \n  str[i]\u003d\u003d'i' || str[i]\u003d\u003d'I' || str[i]\u003d\u003d'o' || str[i]\u003d\u003d'O' || \n  str[i]\u003d\u003d'u' ||str[i]\u003d\u003d'U')\n  {\n   cv++;\n  }\n }\n \n // Printing total number of vowels\n printf(\"Entered String : %s\",str);\n printf(\"\\nTotal number of vowels : %d\",cv);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings4.html#23\" name\u003d\"23\"\u003e23. Program to accept a string and display frequency of each vowel along with vowel\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Declaring variable ca\u003dcount vowel a\n int ca\u003d0, ce\u003d0, ci\u003d0, co\u003d0, cu\u003d0;\n \n // Declaring variable i\u003dto iterate loop ( i works as index position)\n int i;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Determining frequency of each vowel\n for(i\u003d0;str[i]!\u003d'\\0';i++)\n {\n  if(str[i]\u003d\u003d'a' || str[i]\u003d\u003d'A')\n  ca++;\n  \n  if(str[i]\u003d\u003d'e' || str[i]\u003d\u003d'E')\n  ce++;\n  \n  if(str[i]\u003d\u003d'i' || str[i]\u003d\u003d'I')\n  ci++;\n  \n  if(str[i]\u003d\u003d'o' || str[i]\u003d\u003d'O')\n  co++;\n  \n  if(str[i]\u003d\u003d'u' || str[i]\u003d\u003d'U')\n  cu++;\n  \n }\n \n // Printing string\n printf(\"Entered String : %s\",str);\n \n // Printing frequency of string\n printf(\"\\nFrequency of 'a' or 'A' : %d\",ca);\n printf(\"\\nFrequency of 'e' or 'E' : %d\",ce);\n printf(\"\\nFrequency of 'i' or 'I : %d\",ci);\n printf(\"\\nFrequency of 'o' or 'O' : %d\",co);\n printf(\"\\nFrequency of 'u' or 'U' : %d\",cu);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings4.html#24\" name\u003d\"24\"\u003e24. Program to enter a word and check whether it is palindrome or not using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e// palindrom - When word \u003d reverse of word then it is called palindrome\n// Example : madam - palindrome, Madam - not palindrome, MadaM - palindrome\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring \n char word[50], word1[50];\n \n // Inputing string\n printf(\"Enter any word : \");\n scanf(\"%s\",\u0026amp;word);\n\n // Copying word to word1\n strcpy(word1,word);\n \n // checking if palindrome or not\n if(strcmp(word,strrev(word1))\u003d\u003d0)\n {\n  printf(\"Entered word is a palindrome \");\n }\n \n else\n printf(\"Entered word is not palindrome \");\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings4.html#25\" name\u003d\"25\"\u003e25. Program to enter a word and check whether it is palindrome or not without using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring \n char word[50], revword[50];\n \n /* Declaring variable i\u003dto iterate loop, l\u003dlength, \n c\u003dcount the number of matched character */\n int i, j, l\u003d0, c;\n \n // Inputing string\n printf(\"Enter any word : \");\n scanf(\"%s\",\u0026amp;word);\n\n // finding length\n while(word[l]!\u003d'\\0')\n l++;\n \n // Reversing string\n j\u003d0;\n for(i\u003dl-1;i\u0026gt;\u003d0;i--)\n {\n  revword[j]\u003dword[i];\n  j++;\n }\n revword[j]\u003d'\\0';\n \n //checking if palindrome or not\n c\u003d0;\n for(i\u003d0;word[i]!\u003d'\\0';i++)\n {\n  if(revword[i]\u003d\u003dword[i])\n  c++;\n }\n \n if(c\u003d\u003dl)\n {\n  printf(\"Word is a palindrome \");\n }\n \n else\n printf(\"Word is not palindrome \");\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/2178441596240428818/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings4.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/2178441596240428818"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/2178441596240428818"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings4.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8155720132451611306"},"published":{"$t":"2014-01-29T06:24:00.000-08:00"},"updated":{"$t":"2014-04-16T01:03:41.196-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : STRINGS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings3.html#16\" name\u003d\"p16\"\u003e16. Program to convert all characters in a string to lower case using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Printing string\n printf(\"Entered String : %s\\n\",str);\n \n // Converting to lower case\n strlwr(str);\n \n // Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\u003c/pre\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings3.html#17\" name\u003d\"p17\"\u003e17. Program to convert all characters in a string to lower case without using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring, ch\u003dcharacter\n char str[50], ch;\n \n // Declaring variable i\u003dto iterate loop\n int i;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Printing string\n printf(\"Entered String : %s\\n\",str);\n \n  \n // Converting to lower case\n for(i\u003d0;str[i]!\u003d'\\0';i++)\n    {\n        ch\u003dstr[i];\n        \n        if(ch\u0026gt;\u003d65 \u0026amp;\u0026amp; ch\u0026lt;97)\n        {\n            ch+\u003d32; // ch1\u003dch1+32\n            str[i]\u003dch;\n        }\n    }\n    \n    // Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings3.html#18\" name\u003d\"p18\"\u003e18. Program to convert all characters in a string to upper case using string function\u003cbr /\u003e\n\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Printing string\n printf(\"Entered String : %s\\n\",str);\n \n // Converting to lower case\n strupr(str);\n \n // Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings3.html#19\" name\u003d\"p19\"\u003e19. Program to convert all characters in a string to upper case without using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring, ch\u003dcharacter\n char str[50], ch;\n \n // Declaring variable i\u003dto iterate loop\n int i;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Printing string\n printf(\"Entered String : %s\\n\",str);\n \n  \n // Converting to lower case\n for(i\u003d0;str[i]!\u003d'\\0';i++)\n    {\n        ch\u003dstr[i];\n        \n        if(ch\u0026gt;\u003d97 \u0026amp;\u0026amp; ch\u0026lt;\u003d122)\n        {\n            ch-\u003d32; // ch1\u003dch1-32\n            str[i]\u003dch;\n        }\n    }\n    \n    // Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e \u003cspan style\u003d\"color: blue;\"\u003ereturn 0;\u003c/span\u003e\n\u003cspan style\u003d\"color: blue;\"\u003e}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings3.html#20\" name\u003d\"p20\"\u003e20. Program to enter 5 string and print them with their length\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n /* Declaring variable str[5][50]- This means that 5 string is to be input \n with max size of each string \u003d 50 */\n char str[5][50];\n \n // Declaring variable i\u003dto iterate loop\n int i;\n \n // Inputing string\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  printf(\"Enter %d string : \", i+1);\n  gets(str[i]);\n }\n \n // Printing string with its length\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  printf(\"\\nString %d : %s \",i+1, str[i]);\n  printf(\"\\nString length : %d\",strlen(str[i]));\n }\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/8155720132451611306/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings3.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8155720132451611306"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8155720132451611306"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings3.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-594002653997889306"},"published":{"$t":"2014-01-29T06:14:00.000-08:00"},"updated":{"$t":"2014-04-16T01:04:11.102-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : STRINGS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#10\" name\u003d\"p10\"\u003e10. Program for Compare two String using String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring1 , str2\u003dstring2\n char str1[50], str2[50];\n \n // Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n // Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n // Comparing string\n if(strcmp(str1,str2)\u003d\u003d0)\n {\n  printf(\"Same string or string are equal\");\n }\n \n else if(strcmp(str1,str2)\u0026lt;0)\n {\n  printf(\"First string is smaller \");\n }\n \n else if(strcmp(str1,str2)\u0026gt;0)\n {\n  printf(\"Second string is smaller \");\n }\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#11\" name\u003d\"p11\"\u003e11. Program for Compare two String without using String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n  // Declaring variable str1\u003dstring1, str2\u003dstring2\n  char str1[50],str2[50];\n  \n  // Declaring variable ch1\u003dcharacter of string1, ch2\u003dcharacter of string2\n  char ch1,ch2;\n  \n  // Declaring variable i\u003dto iterate loop, flag \u003d to indicate comparision\n     int i,flag\u003d0;\n               \n        // Inputing string       \n        printf(\"\\nEnter First String : \" );\n        gets(str1);\n        \n        printf(\"\\nEnter Second String : \" );\n     gets(str2);\n     \n     // Comparing string\n  for(i\u003d0;str1[i]!\u003d'\\0';i++)\n        {\n            ch1\u003dstr1[i];\n            ch2\u003dstr2[i];\n            if(ch1\u0026gt;\u003d97 \u0026amp;\u0026amp; ch1\u0026lt;\u003d122)\n            {\n                ch1-\u003d32; // ch1\u003dch1-32\n            }\n            if(ch2\u0026gt;\u003d97 \u0026amp;\u0026amp; ch2\u0026lt;\u003d122)\n            {\n                ch2-\u003d32; // ch2\u003dch2-32\n            }\n            if(ch1!\u003dch2)\n            {\n                flag\u003d1;\n                break;\n            }\n        }\n               if(flag\u003d\u003d0)\n                   {\n                        printf(\"\\nString  '%s' and  '%s' are equal \",str1,str2);\n                   }\n               else\n                   {\n                        printf(\"\\nString  '%s' and  '%s' are Not equal \",str1,str2);\n                   }\n\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#12\" name\u003d\"p12\"\u003e12. Program for String Reverse with String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n\n // Printing string and reversed string\n printf(\"String : %s\\n\",str);\n printf(\"Reversed string : %s\",strrev(str));\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#13\" name\u003d\"p10\"\u003e13. Program for String Reverse without String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring, revstr[50]\u003dreverse string\n char str[50], revstr[50];\n \n // Declaring variable i\u003dto iterate loop, l\u003dlength\n int i, j,l\u003d0;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n\n // finding length\n while(str[l]!\u003d'\\0')\n l++;\n \n // Reversing string\n j\u003d0;\n for(i\u003dl-1;i\u0026gt;\u003d0;i--)\n {\n  revstr[j]\u003dstr[i];\n  j++;\n }\n revstr[j]\u003d'\\0';\n \n // Printing string and reversed string\n printf(\"String : %s\\n\",str);\n printf(\"Reversed string : %s\",revstr);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#14\" name\u003d\"p14\"\u003e14. Program for String Concatenation with String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring1 , str2\u003dstring2\n char str1[50], str2[50];\n \n // Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n // Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n // Concatinating string\n strcat(str1,str2); // str2 is added to str1\n \n // Printing conactinated string\n printf(\"Concatinated string : %s\\n\",str1);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strigns2.html#15\" name\u003d\"p15\"\u003e15. Program for String Concatenation without String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring1 , str2\u003dstring2\n char str1[100], str2[50];\n \n // Declaring variable l\u003dlength of string1\n int l1\u003d0;\n \n // Declaring variable i\u003dto iterate loop\n int i;\n \n // Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n // Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n // Finding length of string1 and string2\n while(str1[l1]!\u003d'\\0')\n l1++;\n \n // Concatinating string\n for(i\u003d0;i\u0026lt;str2[i]!\u003d'\\0';i++)\n {\n  str1[l1++]\u003dstr2[i];\n }\n str1[l1]\u003d'\\0';\n\n // Printing Concatinated stirng\n  printf(\"Concatinated string : %s\\n\",str1);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/594002653997889306/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strigns2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/594002653997889306"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/594002653997889306"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strigns2.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-555835272151975336"},"published":{"$t":"2014-01-29T06:05:00.000-08:00"},"updated":{"$t":"2014-04-16T01:04:15.422-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : STRINGS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings1.html#p6\" name\u003d\"p6\"\u003e6. Program to find length of a string using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Declaring variable l\u003dlength\n int l\u003d0;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Determining string length\n l\u003dstrlen(str);\n \n // Printing string length\n printf(\"String : %s\\nString length : %d\",str,l);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings1.html#p7\" name\u003d\"p7\"\u003e7. Program to find length of a string without using string function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring \n char str[50];\n \n // Declaring variable l\u003dlength\n int l\u003d0;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Determining string length\n while(str[l]!\u003d'\\0')\n {\n  l++;\n }\n \n // Printing string length\n printf(\"String : %s\\nString length : %d\",str,l);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings1.html#p8\" name\u003d\"p8\"\u003e8. Program for Copy a String to another using String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n // Declaring variable str\u003dstring , cs\u003dcopied string\n char str[50], cs[50];\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n // Copy string\n strcpy(cs,str);\n \n // Printing string\n printf(\"String : %s\\n\",str);\n printf(\"Copied string : %s\",cs);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings1.html#p9\" name\u003d\"p9\"\u003e9. Program for Copy a String to another without using String Function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dstring , cs\u003dcopied string\n char str[50], cs[50];\n \n // Declaring variable l\u003dlength\n int l\u003d0;\n \n // Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n while(str[l]!\u003d'\\0')\n {\n  cs[l]\u003dstr[l];\n  l++;\n }\n cs[l]\u003d'\\0';\n \n // Printing string\n printf(\"String : %s\\n\",str);\n printf(\"Copied string : %s\",cs);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/555835272151975336/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/555835272151975336"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/555835272151975336"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings1.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6997950191772861278"},"published":{"$t":"2014-01-29T05:57:00.000-08:00"},"updated":{"$t":"2015-03-01T05:35:57.093-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003ctitle\u003eC PROGRAMS : STRINGS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings.html#p1\" name\u003d\"p1\"\u003e1. Program to accept a string and print it\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\n\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable str\u003dto store string inputted by user\n char str[80];\n \n // Inputing string\n printf(\"Enter any sentence : \");\n gets(str);\n \n // printing string\n printf(\"\\nEntered String : \");\n puts(str);\n \n // Another way of printing string\n printf(\"\\nEnterd string : %s\",str);\n  \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings.html#p2\" name\u003d\"p2\"\u003e2. Program to accept a character in the uppercase and print in lower case\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\n\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n //Declaring variable ch to hold character value and cl\u003dchange to lower case \n char ch,cl;\n\n // Inputting character\n printf(\"Enter a character in uppercase : \");\n ch\u003dgetchar();\n \n // Converting it to lower case\n cl\u003dch+32;\n \n // Printing lower case character\n printf(\"The given character in lowercase is : %c \\n\",cl);\n \n // Another way of priting\n printf(\"The given character in lowercase is : \");\n putchar(cl);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings.html#p3\" name\u003d\"p3\"\u003e3. Program to accept a character in Lower case and print it in upper case\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\n\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main( )\n{\n // Declaring variable ch\u003dcharacter, cu\u003dchange character to upper case\n char ch,cu; \n \n // Entering character\n printf(\"Enter a charcater in lower case: \");\n scanf(\"%c\",\u0026amp;ch);\n \n // Converting it to upper case\n cu\u003dch-32;\n \n // Printing upper case character\n printf(\"The given character in upper case is : %c \\n\",cu);\n \n  getch( ); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n  return 0;\n}\u003c/span\u003e\n\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings.html#p4\" name\u003d\"p4\"\u003e4. Program to accept a character in any case and print in another case\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\n\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable ch to hold character value and cch\u003dchange character\n char ch,cch;\n\n // Inputting character\n printf(\"Enter a character in anycase : \");\n scanf(\"%c\",\u0026amp;ch);\n\n // Changing case\n if(ch\u0026gt;\u003d65 \u0026amp;\u0026amp; ch\u0026lt;\u003d90)\n cch\u003dch+32;\n \n else if(ch\u0026gt;\u003d97 \u0026amp;\u0026amp; ch\u0026lt;\u003d122)\n cch\u003dch-32;\n \n // Printing Changed case\n printf(\"Changed character : %c \",cch);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-strings.html#p5\" name\u003d\"p5\"\u003e5. Program to accept a string and print it by using while loop\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\n\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable ch to store input character\n char ch; \n\n // Inputing and displaying string\n printf(\"Enter a string : \");\n while(( ch\u003dgetchar( ))!\u003d'\\n')\n putchar(ch); \n\n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/6997950191772861278/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/6997950191772861278"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/6997950191772861278"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-strings.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8998084866353750682"},"published":{"$t":"2013-12-03T04:35:00.000-08:00"},"updated":{"$t":"2014-04-16T01:11:53.604-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Common Programming Error"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Learn C"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"COMMON PROGRAMMING ERRORS - STRING"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eCOMMON PROGRAMMING ERRORS - STRING\u003c/title\u003e\u003cbr /\u003e\n\u003cdiv style\u003d\"text-align: left;\"\u003e\u003c/div\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eNot allocating sufficient space in a character array to store the\u003cspan style\u003d\"color: lime;\"\u003e null character\u003c/span\u003e that terminates a string.\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003ePrinting a \u003cspan style\u003d\"color: lime;\"\u003e\"string\"\u003c/span\u003e that does not contain \u003cspan style\u003d\"color: lime;\"\u003eterminating null character.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eProcessing a single character as a string. A string is a pointer - probably a respectably large integer. However, a character is a small integer ( ASCII values range 0-255). On many systems this causes an error, because \u003cspan style\u003d\"color: lime;\"\u003elow memory address\u003c/span\u003e are reserved for special purposes such as operating system interrupt handlers. So\u003cspan style\u003d\"color: lime;\"\u003e \"access violation\"\u003c/span\u003e occurs.\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003ePassing a character as an argument to a function when a string is expected (and vice versa) is a compilation error.\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003e\u0026nbsp;Not including the\u0026nbsp;\u003cspan style\u003d\"color: lime;\"\u003e\u0026lt;string.h\u0026gt;\u003c/span\u003e\u0026nbsp;header when\u0026nbsp;using string functions from the \u003cspan style\u003d\"color: lime;\"\u003estring-handling library.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eNot appending a \u003cspan style\u003d\"color: lime;\"\u003eterminating null character\u003c/span\u003e to the first argument of a\u003cspan style\u003d\"color: lime;\"\u003e strncpy\u003c/span\u003e when the third argument is less than or equal to the length of the string in the second argument.\u003c/li\u003e\n\u003c/ul\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: yellow;\"\u003eMore Informative Posts:\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cul\u003e\u003cli\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/learn-C.html\"\u003eComplete List Of Learn C\u003c/a\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-error-complete-list.html\"\u003eCommon Programming Error - Complete List\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-pointers.html\"\u003eCommon Programming Error - Pointers\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-structures.html\"\u003eCommon Programming Error - Structures\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/8998084866353750682/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-errors-string.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8998084866353750682"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8998084866353750682"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-errors-string.html","title":"COMMON PROGRAMMING ERRORS - STRING"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}}]}});