Thread: C++ Help
View Single Post
Old 02-23-2007   #5
lebanese_a
Registered Member
 
lebanese_a's Avatar
 
Last Online: 04-15-2018
Join Date: Aug 2006
Posts: 1,549
Thanks: 31
Thanked 213 Times in 151 Posts
Groans: 0
Groaned at 1 Time in 1 Post
Default Re: C++ Help

Quote:
Originally Posted by Kingroudy
Code:
int i=0;
char str[500];
int strd[500];
ifstream b_file ( "example.txt" );
b_file>>str[0];
while (str[i]!='.')
{
switch (str[i])
{
       case 'a':
       case 'A':
       strd[i]=0;
       break;
// and here u go on and on and on for b and B, c and C...
}
       cout<<strd[i]<<' ';
       i++;
       b_file>>str[i];
       
}
Donno how to work with C++ so I am commenting 7assab ma fhemet the code based on my knowledge of VB.NET

1-" case 'a':
case 'A':"

in VB.NET you can uppercase or lower case the input (UCase, or LCase) that should remove 1 case through the code and make it smaller if it can be done in C++.
if it can't you should write a function (if they exist in C++) that does that, it will come in handy in big apps.

Kamena about the program, why don't you take the ascii chart, and lets say "A"'s ASCII # is 13 (it's not, I am just giving an example) you can make the app take the ascii # and do minus "ASC(A) - 1" ya3neh for A we will have:

Result = 13 (A's number) - 12 (A-1) that will give 1, for B it will be 14 - 12 = 2 w ... this way you could make one very small code and loop it arround the whole text!
lebanese_a is offline   Reply With Quote