GIDForums  

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

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-May-2007, 06:06
Kimmo Kimmo is offline
Regular Member
 
Join Date: Mar 2007
Location: Finland
Posts: 339
Kimmo is a jewel in the roughKimmo is a jewel in the roughKimmo is a jewel in the rough

Making non-English alphabets work


Hi,

A friend of mine asked me to make a program that asks the user for a name and returns the value calculated based on the given name. The program assigns a value to each alphabetical character and finds a corresponding value for the characters in the name.

I solved this by making an array of chars ['a', 'A' ... 'z','Z','å','Å','ä','Ä','ö','Ö']. The program then makes an array of ints equal to the size of alphabet, which is 29. Then the program uses two for loops to test the characters in the name string against each one in the alphabet array. When the characters match, it assigns the corresponding value from the values array.

The following might clear up the explanation:

CPP / C++ / C Code:
int i, j;         
i = j = 0;
int pituus = strlen(Aakkoset);  // length of the alphabet array "Aakkoset"
for (i = 0; nimi[i] != '\0'; ++i)   // nimi = name string
{
    for (j = 0; j < pituus; j = j + 2)  // skip one letter at a time
    {
            if (nimi[i] == Aakkoset[j])   // test for non-capitals
            {
                summa = summa + arvot[j / 2];
                break;
            }
            else if (nimi[i] == Aakkoset[j + 1])  // test for capitals
            {
                summa = summa + arvot[j / 2];
                break;
            }
            else
            {}
    }
}
The question is is this a slow way of finding the corresponce? Would there be some more simple and effective way?

The actual problem I'm having, though, is that the program doesn't recognize the letters 'ä', 'ö' or 'å' from the Finnish alphabet (giving them no values). The DOS prompt in Win XP doesn't show them either, it displays 'õ' etc. instead. So how should I go about making the program work in this respect? Is this because of the compiler or because of Windows?

I'm using Bloodshed Dev-C++ if it matters.

Cheers.
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

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
Work at home. English proofreader needed. $14.50/hour cascade_soft Member Announcements, Advertisements & Offers 0 05-Jun-2006 01:29
Random access files Krazy_yA C Programming Language 6 07-May-2006 02:44
D3D error when running fullscreen games/programs - help?! daa709 Computer Hardware Forum 4 01-Jul-2005 09:03

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

All times are GMT -6. The time now is 17:40.


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