{"id":26569,"date":"2017-05-31T21:03:41","date_gmt":"2017-05-31T15:33:41","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=26569"},"modified":"2017-05-31T21:03:41","modified_gmt":"2017-05-31T15:33:41","slug":"c-program-to-delete-vowels-from-a-string","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/c-program-to-delete-vowels-from-a-string\/","title":{"rendered":"C program to delete vowels from a string"},"content":{"rendered":"<p>C program to delete vowels from a <a href=\"https:\/\/www.wikitechy.com\/technology\/c-program-to-convert-string-to-integer-without-using-atoi-function\/\">string <\/a>: c program to remove or delete vowels from a string, if the input string is &#8220;c programming&#8221; then output will be &#8220;c prgrmmng&#8221;. In the program we create a new string and process entered string character by <a href=\"https:\/\/www.wikitechy.com\/technology\/reverse-string-in-c\/\">character<\/a>, and if a vowel is found it is not added to new string otherwise the character is added to new string, after the string ends we copy the new <a href=\"https:\/\/www.wikitechy.com\/technology\/reverse-string-in-c\/\">string <\/a>into original string. Finally we obtain a string without any vowels.<\/p>\n[ad type=&#8221;banner&#8221;]\n<h2 id=\"c-programming-code\">C programming code<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">#include &lt;stdio.h&gt;<br\/>#include &lt;string.h&gt;<br\/> <br\/>int check_vowel(char);<br\/> <br\/>int main()<br\/>{<br\/>  char s[100], t[100];<br\/>  int i, j = 0;<br\/> <br\/>  printf(&quot;Enter a string to delete vowels\\n&quot;);<br\/>  gets(s);<br\/> <br\/>  for(i = 0; s[i] != &#039;\\0&#039;; i++) {<br\/>    if(check_vowel(s[i]) == 0) {       \/\/not a vowel<br\/>      t[j] = s[i];<br\/>      j++;<br\/>    }<br\/>  }<br\/> <br\/>  t[j] = &#039;\\0&#039;;<br\/> <br\/>  strcpy(s, t);    \/\/We are changing initial string<br\/> <br\/>  printf(&quot;String after deleting vowels: %s\\n&quot;, s);<br\/> <br\/>  return 0;<br\/>}<br\/> <br\/> <br\/>int check_vowel(char c)<br\/>{<br\/>  switch(c) {<br\/>    case &#039;a&#039;:<br\/>    case &#039;A&#039;:<br\/>    case &#039;e&#039;:<br\/>    case &#039;E&#039;:<br\/>    case &#039;i&#039;:<br\/>    case &#039;I&#039;:<br\/>    case &#039;o&#039;:<br\/>    case &#039;O&#039;:<br\/>    case &#039;u&#039;:<br\/>    case &#039;U&#039;:<br\/>      return 1;<br\/>    default:<br\/>      return 0;<br\/>  }<br\/>}<\/code><\/pre> <\/div>\n<p><strong>Output of program:<\/strong><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-26570\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/without-vowels.png\" alt=\"C program to delete vowels from a string\" width=\"317\" height=\"119\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/without-vowels.png 317w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/without-vowels-300x113.png 300w\" sizes=\"(max-width: 317px) 100vw, 317px\" \/><\/p>\n<h2 id=\"c-programming-code-using-pointers\">C programming code using pointers<\/h2>\n[ad type=&#8221;banner&#8221;]\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">#include&lt;stdio.h&gt;<br\/>#include&lt;stdlib.h&gt;<br\/>#include&lt;string.h&gt;<br\/>#define TRUE 1<br\/>#define FALSE 0<br\/> <br\/>int check_vowel(char);<br\/> <br\/>main()<br\/>{<br\/>   char string[100], *temp, *pointer, ch, *start;<br\/> <br\/>   printf(&quot;Enter a string\\n&quot;);<br\/>   gets(string);<br\/> <br\/>   temp = string;<br\/>   pointer = (char*)malloc(100);<br\/> <br\/>  if( pointer == NULL )<br\/>   {<br\/>      printf(&quot;Unable to allocate memory.\\n&quot;);<br\/>      exit(EXIT_FAILURE);<br\/>   }<br\/> <br\/>   start = pointer;<br\/> <br\/>   while(*temp)<br\/>   {<br\/>      ch = *temp;<br\/> <br\/>      if ( !check_vowel(ch) )<br\/>      {<br\/>         *pointer = ch;<br\/>         pointer++;<br\/>      }<br\/>      temp++;<br\/>   }<br\/>   *pointer = &#039;\\0&#039;;<br\/> <br\/>   pointer = start;<br\/>   strcpy(string, pointer); \/* If you wish to convert original string *\/<br\/>   free(pointer);<br\/> <br\/>   printf(&quot;String after removing vowel is \\&quot;%s\\&quot;\\n&quot;, string);<br\/> <br\/>   return 0;<br\/>}<br\/> <br\/>int check_vowel(char a)<br\/>{<br\/>   if ( a &gt;= &#039;A&#039; &amp;&amp; a &lt;= &#039;Z&#039; )<br\/>      a = a + &#039;a&#039; - &#039;A&#039;;<br\/> <br\/>   if ( a == &#039;a&#039; || a == &#039;e&#039; || a == &#039;i&#039; || a == &#039;o&#039; || a == &#039;u&#039;)<br\/>      return TRUE;<br\/> <br\/>   return FALSE;<br\/>}<\/code><\/pre> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>C program to delete vowels from a string &#8211; C Programming &#8211; In the program we create a new string and process entered string character by character.<\/p>\n","protected":false},"author":2,"featured_media":26581,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69866],"tags":[79175,79176,79177,79197,79183,79184,73163,73158,79189,79178,79179,79188,79185,79192,79190,79180,79187,79181,79194,79193,79170,79172,79169,79198,74751,79195,76930,73395,79196,76938,79186,73148,73458,79191,79182,76922,79173,79171,79174],"class_list":["post-26569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-c-program-to-delete-a-character-from-a-string","tag-c-program-to-delete-consonants-in-a-string","tag-c-program-to-delete-vowels-from-a-string","tag-c-program-to-find-vowels-and-consonants-in-a-string","tag-c-program-to-find-vowels-in-a-string","tag-c-program-to-print-vowels-in-a-string","tag-c-string-compare","tag-c-string-functions","tag-char-to-string-java-java-string-replace","tag-delete-string-c","tag-delete-string-in-c","tag-java-char-to-string","tag-java-program-to-find-vowels-and-consonants-in-a-string","tag-java-program-to-find-vowels-in-a-string","tag-javascript-remove-character-from-string","tag-new-string","tag-python-remove-character-from-string","tag-python-trim-string","tag-remove-character-from-string","tag-remove-last-character-from-string-c","tag-remove-vowels-from-a-string-in-c","tag-remove-vowels-from-string-c","tag-remove-vowels-from-string-java","tag-replace-string-java","tag-string-compare-in-c","tag-string-erase","tag-string-functions-in-c","tag-string-in-c","tag-string-in-c-programming","tag-string-manipulation-in-c","tag-string-methods","tag-string-programs-in-c","tag-string-programs-in-java","tag-string-remove","tag-string-slice","tag-strings-in-c","tag-wap-to-enter-the-string-remove-the-blank-spaces-from-the-string","tag-wap-to-remove-the-vowels-from-the-input-string-in-java","tag-write-a-c-program-to-add-all-elements-of-a-matrix-by-using-dynamic-memory-allocation"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/26569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=26569"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/26569\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media\/26581"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=26569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=26569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=26569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}