// API callback
relpostimgcuplik({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Learn C"},{"term":"Common Programming Error"},{"term":"searching and sorting"},{"term":"control sturctures"},{"term":"Fundamental"},{"term":"List of C Programs"},{"term":"string"},{"term":"Array"},{"term":"Pattern"},{"term":"Contents"},{"term":"Pointers"},{"term":"functions"},{"term":"Dynamic memory allcation"},{"term":"recursion"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Structures"}],"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.comp-psyche.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/-\/string?alt=json-in-script\u0026max-results=50"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/search\/label\/string"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#21\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, word=to store the word\n char str[50], word[50];\n \n \/* Declaring variable cw=count words, i=to iterate loop, \n j=works as index position of word *\/\n int cw=0, i, j=0;\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=0;str[i]!='\\0';i++)\n {\n  if(str[i]!=' ')\n  {\n   word[j++]=str[i];\n  }\n  else\n  {\n   word[j]='\\0';\n   printf(\"\\nWord : %s\",word);\n   cw++;\n   j=0;\n  }\n }\n \n \/\/ Printing total words\n printf(\"\\nTotal number of words : %d\",cw);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#22\" name=\"22\"\u003E22. Program to accept a string and display vowels frequency( total number of vowels)\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/* Declaring variable cv=count vowel, i=to iterate loop \n ( i works as index position) *\/\n int cv=0, i;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Checking if vowels and counting them\n for(i=0;str[i]!='\\0';i++)\n {\n  if(str[i]=='a' || str[i]=='A' || str[i]=='e' || str[i]=='E' || \n  str[i]=='i' || str[i]=='I' || str[i]=='o' || str[i]=='O' || \n  str[i]=='u' ||str[i]=='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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#23\" name=\"23\"\u003E23. Program to accept a string and display frequency of each vowel along with vowel\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable ca=count vowel a\n int ca=0, ce=0, ci=0, co=0, cu=0;\n \n \/\/ Declaring variable i=to 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=0;str[i]!='\\0';i++)\n {\n  if(str[i]=='a' || str[i]=='A')\n  ca++;\n  \n  if(str[i]=='e' || str[i]=='E')\n  ce++;\n  \n  if(str[i]=='i' || str[i]=='I')\n  ci++;\n  \n  if(str[i]=='o' || str[i]=='O')\n  co++;\n  \n  if(str[i]=='u' || str[i]=='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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#24\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ palindrom - When word = 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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \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))==0)\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#25\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char word[50], revword[50];\n \n \/* Declaring variable i=to iterate loop, l=length, \n c=count the number of matched character *\/\n int i, j, l=0, c;\n \n \/\/ Inputing string\n printf(\"Enter any word : \");\n scanf(\"%s\",\u0026amp;word);\n\n \/\/ finding length\n while(word[l]!='\\0')\n l++;\n \n \/\/ Reversing string\n j=0;\n for(i=l-1;i\u0026gt;=0;i--)\n {\n  revword[j]=word[i];\n  j++;\n }\n revword[j]='\\0';\n \n \/\/checking if palindrome or not\n c=0;\n for(i=0;word[i]!='\\0';i++)\n {\n  if(revword[i]==word[i])\n  c++;\n }\n \n if(c==l)\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#16\" name=\"p16\"\u003E16. Program to convert all characters in a string to lower case using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#17\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, ch=character\n char str[50], ch;\n \n \/\/ Declaring variable i=to 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=0;str[i]!='\\0';i++)\n    {\n        ch=str[i];\n        \n        if(ch\u0026gt;=65 \u0026amp;\u0026amp; ch\u0026lt;97)\n        {\n            ch+=32; \/\/ ch1=ch1+32\n            str[i]=ch;\n        }\n    }\n    \n    \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#18\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#19\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, ch=character\n char str[50], ch;\n \n \/\/ Declaring variable i=to 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=0;str[i]!='\\0';i++)\n    {\n        ch=str[i];\n        \n        if(ch\u0026gt;=97 \u0026amp;\u0026amp; ch\u0026lt;=122)\n        {\n            ch-=32; \/\/ ch1=ch1-32\n            str[i]=ch;\n        }\n    }\n    \n    \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Ereturn 0;\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#20\" name=\"p20\"\u003E20. Program to enter 5 string and print them with their length\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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 = 50 *\/\n char str[5][50];\n \n \/\/ Declaring variable i=to iterate loop\n int i;\n \n \/\/ Inputing string\n for(i=0;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=0;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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#10\" name=\"p10\"\u003E10. Program for Compare two String using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\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)==0)\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#11\" name=\"p11\"\u003E11. Program for Compare two String without using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n  \/\/ Declaring variable str1=string1, str2=string2\n  char str1[50],str2[50];\n  \n  \/\/ Declaring variable ch1=character of string1, ch2=character of string2\n  char ch1,ch2;\n  \n  \/\/ Declaring variable i=to iterate loop, flag = to indicate comparision\n     int i,flag=0;\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=0;str1[i]!='\\0';i++)\n        {\n            ch1=str1[i];\n            ch2=str2[i];\n            if(ch1\u0026gt;=97 \u0026amp;\u0026amp; ch1\u0026lt;=122)\n            {\n                ch1-=32; \/\/ ch1=ch1-32\n            }\n            if(ch2\u0026gt;=97 \u0026amp;\u0026amp; ch2\u0026lt;=122)\n            {\n                ch2-=32; \/\/ ch2=ch2-32\n            }\n            if(ch1!=ch2)\n            {\n                flag=1;\n                break;\n            }\n        }\n               if(flag==0)\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#12\" name=\"p12\"\u003E12. Program for String Reverse with String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#13\" name=\"p10\"\u003E13. Program for String Reverse without String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string, revstr[50]=reverse string\n char str[50], revstr[50];\n \n \/\/ Declaring variable i=to iterate loop, l=length\n int i, j,l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n\n \/\/ finding length\n while(str[l]!='\\0')\n l++;\n \n \/\/ Reversing string\n j=0;\n for(i=l-1;i\u0026gt;=0;i--)\n {\n  revstr[j]=str[i];\n  j++;\n }\n revstr[j]='\\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#14\" name=\"p14\"\u003E14. Program for String Concatenation with String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#15\" name=\"p15\"\u003E15. Program for String Concatenation without String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\n char str1[100], str2[50];\n \n \/\/ Declaring variable l=length of string1\n int l1=0;\n \n \/\/ Declaring variable i=to 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]!='\\0')\n l1++;\n \n \/\/ Concatinating string\n for(i=0;i\u0026lt;str2[i]!='\\0';i++)\n {\n  str1[l1++]=str2[i];\n }\n str1[l1]='\\0';\n\n \/\/ Printing Concatinated stirng\n  printf(\"Concatinated string : %s\\n\",str1);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p6\" name=\"p6\"\u003E6. Program to find length of a string using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Determining string length\n l=strlen(str);\n \n \/\/ Printing string length\n printf(\"String : %s\\nString length : %d\",str,l);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p7\" name=\"p7\"\u003E7. Program to find length of a string without using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Determining string length\n while(str[l]!='\\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p8\" name=\"p8\"\u003E8. Program for Copy a String to another using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string , cs=copied 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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p9\" name=\"p9\"\u003E9. Program for Copy a String to another without using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string , cs=copied string\n char str[50], cs[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n while(str[l]!='\\0')\n {\n  cs[l]=str[l];\n  l++;\n }\n cs[l]='\\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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p1\" name=\"p1\"\u003E1. Program to accept a string and print it\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=to 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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p2\" name=\"p2\"\u003E2. Program to accept a character in the uppercase and print in lower case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/Declaring variable ch to hold character value and cl=change to lower case \n char ch,cl;\n\n \/\/ Inputting character\n printf(\"Enter a character in uppercase : \");\n ch=getchar();\n \n \/\/ Converting it to lower case\n cl=ch+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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p3\" name=\"p3\"\u003E3. Program to accept a character in Lower case and print it in upper case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n \/\/ Declaring variable ch=character, cu=change 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=ch-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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p4\" name=\"p4\"\u003E4. Program to accept a character in any case and print in another case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable ch to hold character value and cch=change 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;=65 \u0026amp;\u0026amp; ch\u0026lt;=90)\n cch=ch+32;\n \n else if(ch\u0026gt;=97 \u0026amp;\u0026amp; ch\u0026lt;=122)\n cch=ch-32;\n \n \/\/ Printing Changed case\n printf(\"Changed character : %c \",cch);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p5\" name=\"p5\"\u003E5. Program to accept a string and print it by using while loop\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=getchar( ))!='\\n')\n putchar(ch); \n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003ECOMMON PROGRAMMING ERRORS - STRING\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Cdiv style=\"text-align: left;\"\u003E\u003C\/div\u003E\u003Cul style=\"text-align: left;\"\u003E\u003Cli style=\"text-align: justify;\"\u003ENot allocating sufficient space in a character array to store the\u003Cspan style=\"color: lime;\"\u003E null character\u003C\/span\u003E that terminates a string.\u003C\/li\u003E\n\u003C\/ul\u003E\u003Cul style=\"text-align: left;\"\u003E\u003Cli style=\"text-align: justify;\"\u003EPrinting a \u003Cspan style=\"color: lime;\"\u003E\"string\"\u003C\/span\u003E that does not contain \u003Cspan style=\"color: lime;\"\u003Eterminating null character.\u003C\/span\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003Cul style=\"text-align: left;\"\u003E\u003Cli style=\"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=\"color: lime;\"\u003Elow memory address\u003C\/span\u003E are reserved for special purposes such as operating system interrupt handlers. So\u003Cspan style=\"color: lime;\"\u003E \"access violation\"\u003C\/span\u003E occurs.\u003C\/li\u003E\n\u003C\/ul\u003E\u003Cul style=\"text-align: left;\"\u003E\u003Cli style=\"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=\"text-align: left;\"\u003E\u003Cli style=\"text-align: justify;\"\u003E\u0026nbsp;Not including the\u0026nbsp;\u003Cspan style=\"color: lime;\"\u003E\u0026lt;string.h\u0026gt;\u003C\/span\u003E\u0026nbsp;header when\u0026nbsp;using string functions from the \u003Cspan style=\"color: lime;\"\u003Estring-handling library.\u003C\/span\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003Cul style=\"text-align: left;\"\u003E\u003Cli style=\"text-align: justify;\"\u003ENot appending a \u003Cspan style=\"color: lime;\"\u003Eterminating null character\u003C\/span\u003E to the first argument of a\u003Cspan style=\"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=\"text-align: justify;\"\u003E\u003Cspan style=\"color: yellow;\"\u003EMore Informative Posts:\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cul\u003E\u003Cli\u003E\u003Cspan style=\"color: yellow;\"\u003E\u003Ca href=\"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=\"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=\"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=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}}]}});