By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 2,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

hi friends

P: n/a
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K

Jun 27 '06 #1
Share this Question
Share on Google+
16 Replies


P: n/a
appi wrote:
AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.


Shouting on Usenet does not get you friends.

--
Chris "hush" Dollin
"People are part of the design. It's dangerous to forget that." /Star Cops/

Jun 27 '06 #2

P: n/a

appi wrote:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K


Internet lesson 1: SHOUTING AT PEOPLE IS VERY VERY RUDE!

Usenet lesson 1: comp.lang.c deals with C not any of the other stuff
you mention.

c.l.c lesson 1:
<http://www.clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Good luck!

Jun 27 '06 #3

P: n/a
appi said:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K


#include <stdio.h>
#include <ctype.h>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));
}

return 0;
}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 27 '06 #4

P: n/a
Richard Heathfield wrote:
appi said:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K


#include <stdio.h>
#include <ctype.h>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));

<snip>

What is the cast supposed to accomplish here? If I've understood the
standard correctly, nothing.

Is it supposed to accomplish something in general? If 'ch' were not
representable as an unsigned char, you avoid undefined behavior with an
explicit conversion, but since the end result is still indeterminate to a
portable program, this doesn't seem like a big win (it's a small win, since
you at least know your program will output gibberish at the worst, rather
than launch the nuclear missiles, but still).

If invalid values are expected, the program should handle their occurrence
explicitly. If the most appropriate explicit handling turns out to be
converting the values explicitly and hoping for the best, then that's fine,
but I wouldn't insert that reflexively.

S.
Jun 27 '06 #5

P: n/a
Skarmander wrote:

Richard Heathfield wrote:
putchar(tolower((unsigned char)ch));

What is the cast supposed to accomplish here? If I've understood the
standard correctly, nothing.

Is it supposed to accomplish something in general?


Yes.
If ch is a negative value,
and if ((unsigned char)ch) compares equal to 'A',
then putchar(ch) will output 'A'.

--
pete
Jun 27 '06 #6

P: n/a
pete wrote:
Skarmander wrote:
Richard Heathfield wrote:

putchar(tolower((unsigned char)ch));

What is the cast supposed to accomplish here? If I've understood the
standard correctly, nothing.

Is it supposed to accomplish something in general?


Yes.
If ch is a negative value,
and if ((unsigned char)ch) compares equal to 'A',
then putchar(ch) will output 'A'.

But why would this be useful? How would you obtain such values, and why
would you use them?

S.
Jun 27 '06 #7

P: n/a
Skarmander wrote:

pete wrote:
Skarmander wrote:
Richard Heathfield wrote:

putchar(tolower((unsigned char)ch));

What is the cast supposed to accomplish here?
If I've understood the
standard correctly, nothing.

Is it supposed to accomplish something in general?


Yes.
If ch is a negative value,
and if ((unsigned char)ch) compares equal to 'A',
then putchar(ch) will output 'A'.

But why would this be useful?
How would you obtain such values, and why
would you use them?


In the C locale,
which is what the program in question was,
I don't think it matters.

But I took your phrase "in general"
to imply "regardless of locale".

N869
7.4 Character handling <ctype.h>

[#2] The behavior of these functions is affected by the
current locale.

--
pete
Jun 27 '06 #8

P: n/a
pete wrote:
Skarmander wrote:
pete wrote:
Skarmander wrote:
Richard Heathfield wrote:
> putchar(tolower((unsigned char)ch));
What is the cast supposed to accomplish here?
If I've understood the
standard correctly, nothing.

Is it supposed to accomplish something in general?
Yes.
If ch is a negative value,
and if ((unsigned char)ch) compares equal to 'A',
then putchar(ch) will output 'A'.

But why would this be useful?
How would you obtain such values, and why
would you use them?


In the C locale,
which is what the program in question was,
I don't think it matters.

But I took your phrase "in general"
to imply "regardless of locale".

N869
7.4 Character handling <ctype.h>

[#2] The behavior of these functions is affected by the
current locale.

"Regardless of locale" just means the program can't assume a particular
locale to be in effect.

I didn't mean to ask if there was some possibility that the statement
putchar(tolower((unsigned char) ch));
occurring in some program, using some locale, has a reason for the cast to
be there. Of course there will be such programs and locales. The question is
whether there's any other interpretation of that cast *in general* than a
slightly questionable attempt at error handling.

Either the value you're working with is expected, or it isn't. If it isn't,
converting makes little sense (except to convert potentially undefined
behavior into potentially gibberish output, which may have some extrinsic
value). If it is, converting makes sense only for some particular algorithm
in combination with some particular locales, which was not the context I was
talking about.

S.
Jun 27 '06 #9

P: n/a
appi wrote:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
Are all of the above included in your syllabus!?

Try to learn one langauge at a time. It's better to know one or two
langauges really well than hack around with several langauges. I
suggest you learn C, SQL and HTML to start with. I personally favour
Python instead of Java or C++, but YMMV.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.
Firstly, using all caps is considered as shouting. We've left Yahoo!
Chat; we're in Usenet.
Also this group deals with standard C and not general programming. You
might want to post to comp.programming, *but*, before you do that, be
sure to read the information at the following URLs.

<http://cfaj.freeshell.org/google/>
<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
<http://www.safalra.com/special/googlegroupsreply/>
<http://en.wikipedia.org/wiki/USENET>
<http://en.wikipedia.org/wiki/Netiquette>
AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

I assume you know how to use Google... ?

Jun 27 '06 #10

P: n/a
Richard Heathfield wrote:
appi said:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS. #include <stdio.h>
#include <ctype.h>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));


Is the cast here necessary?
}

return 0;
}


Jun 27 '06 #11

P: n/a
Skarmander said:
Richard Heathfield wrote:
appi said:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K
#include <stdio.h>
#include <ctype.h>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));

<snip>

What is the cast supposed to accomplish here? If I've understood the
standard correctly, nothing.


Since getchar returns an unsigned char converted to int, you're right in
this case. I was over-egging.
Is it supposed to accomplish something in general?


Yes. Consider the following code:

#include <stdio.h>
#define MAXLINE 1024
int main(void)
{
char line[MAXLINE];
while(fgets(line, sizeof line, stdin) != NULL)
{
size_t i;
for i = 0; line[i] != '\0'; i++)
{
putchar(tolower(line[i])); /* BUG - see below */
}
}
return 0;
}

Consider a user who manages to input "special characters" (e.g. in MS-DOS,
he types Alt-0156 to get a UKP sign), that are not in the range 0 to
UCHAR_MAX. fgets will capture these correctly, as unsigned chars, but then
assign them into members of the line array, which are chars. If we continue
with our MS-DOS example, the char value will be *negative*. When this value
is passed to tolower(), it will be promoted to int, but it will still be
negative. So if tolower() is implemented as an array lookup (which is
perfectly legal), the offset into that array will be negative for this
character. Bang, as they say. Converting the character to unsigned char
explicitly, on the other hand, means that everything comes out in the wash
and the character is handled correctly.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 27 '06 #12

P: n/a
santosh said:
Richard Heathfield wrote:

<snip>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));


Is the cast here necessary?


It's one of those times when a habit that /can/ save your bacon /doesn't/
save your bacon because, in this exact circumstance, your bacon is not
endangered. That doesn't mean it's a mistake to have developed the habit.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 27 '06 #13

P: n/a
Richard Heathfield wrote:
Skarmander said:
Richard Heathfield wrote: <snip>
#include <stdio.h>
#include <ctype.h>

int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));

<snip>

What is the cast supposed to accomplish here? If I've understood the
standard correctly, nothing.


Since getchar returns an unsigned char converted to int, you're right in
this case. I was over-egging.
Is it supposed to accomplish something in general?


Yes. Consider the following code:

#include <stdio.h>
#define MAXLINE 1024
int main(void)
{
char line[MAXLINE];
while(fgets(line, sizeof line, stdin) != NULL)
{
size_t i;
for i = 0; line[i] != '\0'; i++)
{
putchar(tolower(line[i])); /* BUG - see below */
}
}
return 0;
}

Consider a user who manages to input "special characters" (e.g. in MS-DOS,
he types Alt-0156 to get a UKP sign), that are not in the range 0 to
UCHAR_MAX. fgets will capture these correctly, as unsigned chars, but then
assign them into members of the line array, which are chars. If we continue
with our MS-DOS example, the char value will be *negative*.


Thanks, this is what I was looking for. The problem is not that "invalid"
characters are read, but that 'char' may be signed, whereas the various
character functions expect an unsigned char converted to int.

That's a neat gotcha.

S.
Jun 27 '06 #14

P: n/a
"appi" <co***********@gmail.com> writes:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K


<HTTP://WWW.CATB.ORG/~ESR/FAQS/SMART-QUESTIONS.HTML>

Oops, sorry, I meant

<http://www.catb.org/~esr/faqs/smart-questions.html>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 27 '06 #15

P: n/a
In article <ln************@nuthaus.mib.org>, Keith Thompson <kst-
u@mib.org> writes
"appi" <co***********@gmail.com> writes:
I am learning datastructure using c in my syllabus and i want to learn
about datastructure, c++, java, oracle, web design, html,c#.
SO I AM REQUESTING YOU THAT PLEASE SEND ME SOME INFORMATION
ABOUT THE ABOVE MENTIONED TOPICS.

AND ALSO SEND ME SOME INFORMATION ABOUT INTERNET.

YOURS FAITHFULLY
KIRAN.M.K


<HTTP://WWW.CATB.ORG/~ESR/FAQS/SMART-QUESTIONS.HTML>

Oops, sorry, I meant

<http://www.catb.org/~esr/faqs/smart-questions.html>


I heard you the first time :-)

We could of course actually do what he asks for the next 30 days, send
*ALL* the information you have on datastructures, C++ etc etc to his
email address....

How many Gb does a Gmail account hold?
Be careful what you wish for :-)

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jun 28 '06 #16

P: n/a
Richard Heathfield wrote:
santosh said:

Richard Heathfield wrote:


<snip>
int main(void)
{
int ch;
while((ch = getchar()) != EOF)
{
putchar(tolower((unsigned char)ch));


Is the cast here necessary?

It's one of those times when a habit that /can/ save your bacon /doesn't/
save your bacon because, in this exact circumstance, your bacon is not
endangered. That doesn't mean it's a mistake to have developed the habit.


Mmmm... bacon.

Joe
Jun 29 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.