GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Dec-2007, 12:42
SRTeasy SRTeasy is offline
New Member
 
Join Date: Dec 2007
Posts: 9
SRTeasy is on a distinguished road

Removing Vowels.


I'm a noob and I've just been introduced to programming and C/C++, within the last month.

I've been tasked to write a program (I'm using Visual Studio btw) that reads the standard input file, and writes to the standard output file, deleting all vowels.

i.e.
Prompt user to input text:
Wow, this is fun.
Output:
Ww, ths s fn.
press any key to continue...

Any help would be great, I don't even know where to start.

Thanks
  #2  
Old 28-Dec-2007, 15:42
SRTeasy SRTeasy is offline
New Member
 
Join Date: Dec 2007
Posts: 9
SRTeasy is on a distinguished road

Re: Removing Vowels..


CPP / C++ / C Code:
#include <stdio.h>
#include <ctype.h>

int isvowel(int c);
int main (void)

{
int c;
printf("INPUT YOUR TEXT: \n\n");
while((c = getchar()) != EOF) 
{
if(isvowel(c))
putchar(c);
}
return 0;
}
int isvowel(int c)
{
if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
return 0;
return 1;
}

Ok, after hours of work, I think I figured it out. Now how do I pretty it up by printing "YOUR TEXT WITHOUT VOWELS IS:" before the output and ending the program with "PRESS ANY KEY TO CONTINUE..."?

Thanks
  #3  
Old 28-Dec-2007, 19:39
essaytee essaytee is offline
New Member
 
Join Date: Dec 2007
Location: Melbourne, Australia.
Posts: 7
essaytee is on a distinguished road

Re: Removing Vowels..


I'm learning this stuff (C++) as well and I use this and other forums, the questions asked, in order to cement my learning. I wrote a little program which is one particular way of solving the 'removing characters from a string'. I was about to post my attempt and then realized this is a C forum/thread.

My solution can be found here http://superjacent.net/cms/?q=node/742. I can post here but doesn't really address the C issues.

ps. why don't links work?
  #4  
Old 28-Dec-2007, 21:37
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 613
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Removing Vowels..


Your work pays off. Good getchar() / putchar() examples. I like the function.
re: "pretty it up"
Some ideas:
CPP / C++ / C Code:
#include <stdio.h>                            /* srteasy  srt1.c */
/* #include <ctype.h>  <- you do not need that */

int isvowel(int c);  /* very good */

int main (void)
{
  int c = 0;
  
  /* use loop inside loop to separate the input part from the output part */
  while(c != 0x1b)    /* 0x1b is ascii code for escape key */
  {
    printf("\nINPUT YOUR TEXT:      (ESC to exit) \n"); 
    /* while((c = getchar()) != EOF) */
    while((c = getchar()) != '\n' && c != 0x1b)  /* get out of this loop on either */
    {
      if(isvowel(c))
        putchar(c); /* try writing to a char array here instead of the putchar */
    }
    /* when input is done, you print your fancy message including the string */
    putchar(0x0a);
    /* do you want another getchar() here for "anykey"  ? */
  }
  return 0;
}
  #5  
Old 28-Dec-2007, 23:15
SRTeasy SRTeasy is offline
New Member
 
Join Date: Dec 2007
Posts: 9
SRTeasy is on a distinguished road

Re: Removing Vowels..


Thanks for the input, I will toy around with these ideas..

SRTeasy
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Odd behavior when removing #include statement from source file earachefl C++ Forum 5 09-Feb-2007 12:36
Removing installed program onto usb jamier1985uk Computer Software Forum - Windows 1 16-Jan-2007 11:51
Removing "Please enter an integer" message lti2000 MS Visual C++ / MFC Forum 2 02-Dec-2006 23:04
Removing Characters from a "String" in a Linked List Dave Sinkula C Programming Language 0 02-Jun-2005 10:02
Removing the " underline pointer?" and advance clrscr()? leitz C Programming Language 7 14-Nov-2004 12:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:46.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.