Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > a big problem

Reply
Thread Tools

a big problem

 
 
Jordan Abel
Guest
Posts: n/a
 
      12-26-2005
On 2005-12-25, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> Emmanuel Delahaye wrote:
>> (E-Mail Removed) a crit :
>>
>> > if (scr >= 'A' && scr <= 'Z')

>>
>> Not portable hack. Works fine with ASCII but neither with extended ISO
>> characters (iso-8859-1), nor with EBCDIC for example.
>>

>
> This will work with EBCDIC.


A-Z are in order in EBCDIC but are not contiguous.
 
Reply With Quote
 
 
 
 
Dik T. Winter
Guest
Posts: n/a
 
      12-26-2005
In article <(E-Mail Removed). com> "(E-Mail Removed)" <(E-Mail Removed)> writes:
> Emmanuel Delahaye wrote:
> > (E-Mail Removed) a =E9crit :
> >
> > > if (scr >=3D 'A' && scr <=3D 'Z')

> >
> > Not portable hack. Works fine with ASCII but neither with extended ISO
> > characters (iso-8859-1), nor with EBCDIC for example.

>
> This will work with EBCDIC. It will even work, amazingly, with Baudot.
> In fact, it will even work with Morse code. When designing character
> sets, humans have a tendency to make A-Z contiguous. (Of course, for
> Baudot and Morse A-Z exists but there are no a-z).


Eh? In Baudot the coding of '-' is between 'W' and 'T'. In what you
call Baudot (but actually is Murray), ' ' is between 'O' and 'H'. It
also does not work with EBCDIC because the backslash, the closing brace,
the hook and the fork are also in that range.

So what do you mean when you say that it works?
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      12-26-2005
(E-Mail Removed) wrote:
> How about this?
>
> #include<stdio.h>
>
> int main()
> {
> char scr;
>
> printf("input the character: ");
> scanf("%s", &scr);


Exactly how many characters do you think fit in to a single character?
Add to that C strings are terminated with a nul character and how long a
C string do you think fits in to a single character? In addition, the
"%s" format specifier for scanf (without limiting the length) is just as
bad as gets because it allows the user to enter a longer string than
fits in to the destination thus overwriting memory, so don't do that.

> if (scr >= 'A' && scr <= 'Z')


A-Z are not guaranteed contiguous or to be in sequence. Loot up the is*
functions which are provided for a reason.

> {
> scr += 32;


Upper and lower case letters are not guaranteed to be separated by 32.
Look up the to* functions.

> }
> if (scr >= 'a'&& scr <= 'z')
> {
> scr -= 32;
> }
>
> printf("the result is: %s", &scr);
>
> return 0;
> }
>
> Simple code is ok, i think.


It is simply atrocious code. You still have a *lot* to learn.

> The IDE I used is Dev-C++ 4.9.9.0.


Irrelevant.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      12-26-2005
On 25 Dec 2005 15:22:03 -0800, in comp.lang.c , "(E-Mail Removed)"
<(E-Mail Removed)> wrote:

>When designing character
>sets, humans have a tendency to make A-Z contiguous.


Er... What, you mean like abgdezeth ?

Thats a contiguous alphabetic sequence in the order which would make
perfect sense to millions of people.

(and lets not forget azerty....)

Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
slebetman@yahoo.com
Guest
Posts: n/a
 
      12-27-2005
Mark McIntyre wrote:
> On 25 Dec 2005 15:22:03 -0800, in comp.lang.c , "(E-Mail Removed)"
> <(E-Mail Removed)> wrote:
>
> >When designing character
> >sets, humans have a tendency to make A-Z contiguous.

>
> Er... What, you mean like abgdezeth ?
>
> Thats a contiguous alphabetic sequence in the order which would make
> perfect sense to millions of people.
>
> (and lets not forget azerty....)
>
> Mark McIntyre
>


OK, OK. Sorry I was wrong. I knew I should have checked before posting..

 
Reply With Quote
 
Xiaocao Feidao
Guest
Posts: n/a
 
      12-28-2005
Thank you very much! These faults knocked me back.
非常谢谢*,我对这些错误感动很震惊。
 
Reply With Quote
 
Xiaocao Feidao
Guest
Posts: n/a
 
      12-28-2005
Thank you very much! These faults knocked me back.
非常谢谢*!我对这些错误感到很震惊。
 
Reply With Quote
 
Xiaocao Feidao
Guest
Posts: n/a
 
      12-28-2005
hehe, thanks^_^

 
Reply With Quote
 
Xiaocao Feidao
Guest
Posts: n/a
 
      12-28-2005
thanks.

 
Reply With Quote
 
=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=
Guest
Posts: n/a
 
      12-30-2005
"Malcolm" <(E-Mail Removed)> writes:
> The hard part is addressing the screen. Virtually all C compilers
> come with some sort of non-standard library for accessing character-
> mapped screens.


What is this "screen" you speak of? I've searched through my copy of
the standard but found no mention of it.

DES
--
Dag-Erling Smrgrav - (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM
Big JARs = Big Problems? kk_oop@yahoo.com Java 11 09-18-2005 05:54 PM



Advertisments