English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

As a user inputs a statement like, "How are you?" It will become, "Hw r y?" How is it done? This c is c programming not c++... Thanks!

2007-01-23 17:42:39 · 3 answers · asked by Raksha K 1 in Computers & Internet Programming & Design

3 answers

Assume the input is in a character array (char myInput[50]) and terminated with a null...

char newin[50];
int x=0, y=0;

for (x=0; x if (in[x]!='a' && in[x]!='e' && in[x]!='i' && in[x]!='o' && in[x]!='u' && in[x]!='A' && in[x]!='B' && in[x]!='I' && in[x]!='O' && in[x]!='U')
newin[y++]=in[a];

newin[y]='\0';


Of course, you could use change the if statement to be more elaborate by checking the ascii value knowing that upper and lowercase chars are offset by a value of 32.

2007-01-23 17:59:36 · answer #1 · answered by BigRez 6 · 0 0

A string in C++ ends with a character with ASCII value 0. merely count quantity the variety of characters interior the string that have a value larger than 0. think approximately that the variety of characters could be 0.

2016-11-26 22:39:29 · answer #2 · answered by ? 4 · 0 0

Why don't you want to use strings? Given that the input is a string, I don't see how this could work.

The code to do this is straightforward, just do a byte by byte copy, skipping any input that you don't like.

2007-01-23 17:52:39 · answer #3 · answered by tony1athome 5 · 0 0

fedest.com, questions and answers