473,508 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array

10 New Member
Hi,

Instead of:
char let[26] = {'A','B','C','D','E',...., 'Z''};

What would be another (shorter) way of writing this ?

Thx,
Aug 31 '06 #1
7 2649
rgb
37 New Member
this is dependent on your character set (ASCII will work), you can declare a char data type initialized at first letter of the aplphabet and then increment it (ex. i++) for the next letter on a loop.
Aug 31 '06 #2
help1267
10 New Member
Hi rgb,
thanks for your reply. I'm new at this. Would you be able to elaborate ?

Thx,
Aug 31 '06 #3
D_C
293 Contributor
Banfa mentioned in an earlier post, that only 0-9 are guaranteed to be consecutive, although as is the case for ASCII, a-z are consecutive, as well as A-Z.

With your array, let[0] = 'a', let[25] = 'z'. For 0 <= N <= 25, you could replace let[N] with ('a'+N)
Sep 1 '06 #4
rgb
37 New Member
Banfa mentioned in an earlier post, that only 0-9 are guaranteed to be consecutive, although as is the case for ASCII, a-z are consecutive, as well as A-Z.
as mentioned, the approach is dependent on the charater set. i am not familiar with other sets, most of the time i use ASCII character set.
Sep 1 '06 #5
rgb
37 New Member
Hi,

Instead of:
char let[26] = {'A','B','C','D','E',...., 'Z''};

What would be another (shorter) way of writing this ?

Thx,

you can also use this approach:

char let[ ] = "ABCDEF...XYZ";

the array let[ ] will be indexed the same as yours.

let[0] will be equal to 'A'
let[1] will be equal to 'B'
etc
etc
etc
let[25] will be equal to 'Z'
Sep 1 '06 #6
Talon4196
2 New Member
char let[26];
for (int x = 65; x < 91; x++)
let[x-65] = char(x);
Dec 5 '06 #7
Talon4196
2 New Member
well.. instead of 65, and 91, just use int('A') and int('Z')... 65 and 91 is what the values are for my keyboard...
Dec 5 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2757
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
575
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
5156
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
3465
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
55527
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
10198
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
10048
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
104
16852
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
7
3168
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
17
7211
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.