473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

sob..Someone can help me????plsss

please key in any 5 digits number : 56789
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......

my idea is like this...
#include <stdio.h>

void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);

num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;

r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;

printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);
}
__________________________________________________ ____________________________

the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...

and i really appriciate if someone can make it more efficient....

THX MUahhh

Sep 20 '07 #1
40 2281
On Sep 20, 2:39 pm, aslamhe...@yahoo.com wrote:
please key in any 5 digits number : 56789

and the ouput is
5678 9
567 89
56 789
5 6789

how to write those program......

my idea is like this...
#include <stdio.h>

void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);

num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;

r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;

printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);}

__________________________________________________ _________________________*___

the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...

and i really appriciate if someone can make it more efficient....

THX MUahhh
CORRECTION

On Sep 20, 2:39 pm, aslamhe...@yahoo.com wrote:
please key in any 5 digits number : 56789

and the ouput is
5678 9
567 89
56 789
5 6789

how to write those program......

my idea is like this...
#include <stdio.h>

void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);

num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;

r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;

printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);}

__________________________________________________ _________________________*___

the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...

and i really appreciate if someone can make it more efficient....

THX MUahhh

Sep 20 '07 #2
On Wed, 19 Sep 2007 23:39:27 -0700, aslamhenry wrote:
please key in any 5 digits number : 56789
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......

my idea is like this...
#include <stdio.h>

void main()
main returns an int. See www.c-faq.com, question 1.25b.
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);
[snip]
the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...
The maximum value guaranteed to fit in an int is 32767. Declare
num as a long (you'll need to use "%ld" instead of "%d").
By the way, there is absolutely no need to use floating point
here, integers would do it, or better still consider the input as
a string as you were told in the other thread.
Do like this:
read 6 characters from stdin;
if the first 5 characters are digits and the sixth is whitespace,
the input is ok; process it as you were told in the other thread;
else do something sensible. Note that scanf doesn't touch num if
it fails (e.g. there are no numeric data but letters or
punctuation or else), in which case num stays uninitialized. Don't
use scanf() unless there is no better choice. Hint: there always
is a better choice.

--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 20 '07 #3
On Sep 20, 7:10 pm, Army1987 <army1...@NOSPAM.itwrote:
On Wed, 19 Sep 2007 23:39:27 -0700, aslamhenry wrote:
please key in any 5 digits number : 56789
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......
my idea is like this...
#include <stdio.h>
void main()

main returns an int. Seewww.c-faq.com, question 1.25b.
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;
printf("please key in any 5 digit number:");
scanf("%d",&num);
[snip]
the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....
anyone can tell what wrong with my coding...

The maximum value guaranteed to fit in an int is 32767. Declare
num as a long (you'll need to use "%ld" instead of "%d").
By the way, there is absolutely no need to use floating point
here, integers would do it, or better still consider the input as
a string as you were told in the other thread.
Do like this:
read 6 characters from stdin;
if the first 5 characters are digits and the sixth is whitespace,
the input is ok; process it as you were told in the other thread;
else do something sensible. Note that scanf doesn't touch num if
it fails (e.g. there are no numeric data but letters or
punctuation or else), in which case num stays uninitialized. Don't
use scanf() unless there is no better choice. Hint: there always
is a better choice.

--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid "Smart Quotes" feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen- Hide quoted text -

- Show quoted text -
how to use %ld??since im a newbie....there still a lot of coding that
ive never seen before

Sep 20 '07 #4
On Sep 20, 8:02 am, aslamhe...@yahoo.com wrote:
On Sep 20, 7:10 pm, Army1987 <army1...@NOSPAM.itwrote:


On Wed, 19 Sep 2007 23:39:27 -0700, aslamhenry wrote:
please key in any 5 digits number : 56789
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......
my idea is like this...
#include <stdio.h>
void main()
main returns an int. Seewww.c-faq.com, question 1.25b.
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;
printf("please key in any 5 digit number:");
scanf("%d",&num);
[snip]
the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....
anyone can tell what wrong with my coding...
The maximum value guaranteed to fit in an int is 32767. Declare
num as a long (you'll need to use "%ld" instead of "%d").
By the way, there is absolutely no need to use floating point
here, integers would do it, or better still consider the input as
a string as you were told in the other thread.
Do like this:
read 6 characters from stdin;
if the first 5 characters are digits and the sixth is whitespace,
the input is ok; process it as you were told in the other thread;
else do something sensible. Note that scanf doesn't touch num if
it fails (e.g. there are no numeric data but letters or
punctuation or else), in which case num stays uninitialized. Don't
use scanf() unless there is no better choice. Hint: there always
is a better choice.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid "Smart Quotes" feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen- Hide quoted text -
- Show quoted text -

how to use %ld??since im a newbie....there still a lot of coding that
ive never seen before
Suggestion:
Invest in a C book if you want to learn C.
Try K&R2:
http://cm.bell-labs.com/cm/cs/cbook/

Meanwhile, try a google search like:
http://www.google.com/search?client=...=Google+Search

Sep 20 '07 #5
as********@yahoo.com writes:
[...]
how to use %ld??since im a newbie....there still a lot of coding that
ive never seen before
Please trim quoted text when you post a followup. Quote just enough
of the parent article so your response makes sense on its own. It's
rarely necessary to quote the whole thing.

Using "%ld" is a very elementary part of using printf. If your
textbook is any good, you should be able to find the answer there.

But I'll show you a quick example anyway:

int x = 12345;
long y = 12345678;
printf("x = %d, y = %ld\n", x, y);

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 20 '07 #6
On Sep 20, 2:39 pm, aslamhe...@yahoo.com wrote:
please key in any 5 digits number : 56789

and the ouput is
5678 9
567 89
56 789
5 6789

how to write those program......

my idea is like this...
#include <stdio.h>

void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);

num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;

r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;

printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);}

__________________________________________________ _________________________*___

the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...

and i really appriciate if someone can make it more efficient....
ceh my teacher is totally jerk........now he ask me to do in looping
humm.....i think maybe i can use for...nvm i will try to do on my
own...
i will ask if got any prob....
i think must use nested for...

Sep 20 '07 #7
as********@yahoo.com wrote:
>
.... snip ...
>
ceh my teacher is totally jerk........now he ask me to do in looping
humm.....i think maybe i can use for...nvm i will try to do on my
own...
i will ask if got any prob....
i think must use nested for...
What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces. Sentences are
normally commenced with an upper case letter. All this greatly
improves readability. Other possible sentence terminating
punctuation marks include '!' and '?'. After you get those
straight start thinking about comma, colon, and semi-colon. But
start with period (the one dot).

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 20 '07 #8
On Thu, 20 Sep 2007 18:35:43 -0400, CBFalconer wrote:
What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces.
Not by everybody. Many people follow it with one space.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 20 '07 #9
as********@yahoo.com wrote:
>
On Sep 20, 2:39 pm, aslamhe...@yahoo.com wrote:
please key in any 5 digits number : 56789

and the ouput is
5678 9
567 89
56 789
5 6789

how to write those program......

my idea is like this...
#include <stdio.h>

void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;

printf("please key in any 5 digit number:");
scanf("%d",&num);

num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;

r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;

printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);}

__________________________________________________ _________________________*___

the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....

anyone can tell what wrong with my coding...

and i really appriciate if someone can make it more efficient....
ceh my teacher is totally jerk........now he ask me to do in looping
humm.....i think maybe i can use for...nvm i will try to do on my
own...
i will ask if got any prob....
i think must use nested for...
It's really a string problem and not a math problem.

/* BEGIN new.c */

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

#define LENGTH 5
#define str(x) # x
#define xstr(x) str(x)

int main(void)
{
int rc;
char array[LENGTH + 1];
size_t index, space, loop;

fputs("please key in any 5 digits number :", stdout);
fflush(stdout);
rc = fscanf(stdin, "%" xstr(LENGTH) "[^\n]%*[^\n]", array);
if (!feof(stdin)) {
getc(stdin);
}
if (rc == 0) {
array[0] = '\0';
}
if (rc == EOF) {
puts("rc equals EOF");
exit(EXIT_FAILURE);
}
for (index = 0; index != sizeof array - 1; ++index) {
if (isdigit((unsigned char)array[index]) == 0) {
puts("isnum(array[index]) == 0");
exit(EXIT_FAILURE);
}
}
space = 0;
for (loop = sizeof array - 2; loop != 0; --loop) {
for (index = space; index != 0; --index) {
putchar(' ');
}
for (space += 2; index != loop; ++index) {
putchar(array[index]);
}
putchar(' ');
putchar(' ');
puts(array + index);
}
return 0;
}

--
pete
Sep 21 '07 #10
pete wrote:
>
as********@yahoo.com wrote:

On Sep 20, 2:39 pm, aslamhe...@yahoo.com wrote:
please key in any 5 digits number : 56789
>
and the ouput is
5678 9
567 89
56 789
5 6789
It's really a string problem and not a math problem.

/* BEGIN new.c */

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

#define LENGTH 5
#define str(x) # x
#define xstr(x) str(x)

int main(void)
{
int rc;
char array[LENGTH + 1];
size_t index, space, loop;

fputs("please key in any 5 digits number :", stdout);
I like this better:

printf("please key in any " xstr(LENGTH) " digits number :");

--
pete
Sep 21 '07 #11
Army1987 said:
On Thu, 20 Sep 2007 18:35:43 -0400, CBFalconer wrote:
>What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces.
Not by everybody. Many people follow it with one space.
The two-space gap between sentences goes back to typewriting with a
fixed-pitch font. It was considered to be more aesthetically pleasing than
a single space, although really two spaces was a little too much (but one
space wasn't quite enough!). With the advent of smart word processors that
could put an aesthetically decent gap between one sentence and the next,
given only the hint of a full stop and a space, the practice faded out,
even in Usenet, where fixed-pitch fonts are the norm (presumably because
many people do more typing in word processors or other programs with
proportional fonts than in fixed-pitch programs such as text editors and
good Usenet clients).

I've been using one space as a sentence separator for so long that I cannot
now remember when I made the switch from two spaces.

I'm trying to think up a way to link this to C, but not having a great deal
of success.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 21 '07 #12
CBFalconer <cb********@yahoo.comwrote:
as********@yahoo.com wrote:

ceh my teacher is totally jerk........now he ask me to do in looping
humm.....i think maybe i can use for...nvm i will try to do on my
own...
i will ask if got any prob....
i think must use nested for...

What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces.
One space, in civilised countries.

Richard
Sep 21 '07 #13
Richard Heathfield wrote, On 21/09/07 01:52:
Army1987 said:
>On Thu, 20 Sep 2007 18:35:43 -0400, CBFalconer wrote:
>>What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces.
Not by everybody. Many people follow it with one space.

The two-space gap between sentences goes back to typewriting with a
fixed-pitch font. It was considered to be more aesthetically pleasing than
a single space, although really two spaces was a little too much (but one
space wasn't quite enough!). With the advent of smart word processors that
could put an aesthetically decent gap between one sentence and the next,
given only the hint of a full stop and a space, the practice faded out,
even in Usenet, where fixed-pitch fonts are the norm (presumably because
many people do more typing in word processors or other programs with
proportional fonts than in fixed-pitch programs such as text editors and
good Usenet clients).

I've been using one space as a sentence separator for so long that I cannot
now remember when I made the switch from two spaces.

I'm trying to think up a way to link this to C, but not having a great deal
of success.
You could write a filter program in standard C to adjust your posts so
that they use two spaces.
--
Flash Gordon
Sep 21 '07 #14
On Thu, 20 Sep 2007 20:40:26 -0400, pete wrote:
I like this better:

printf("please key in any " xstr(LENGTH) " digits number :");
If you are indeed using printf, what's wrong with
printf("please key in any %d digits number :", (int)LENGTH)?
It'll continue to work if you define LENGTH in some more insane way.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 21 '07 #15
On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
>I'm trying to think up a way to link this to C, but not having a great deal
of success.

You could write a filter program in standard C to adjust your posts so
that they use two spaces.
It is less trivial than it seems, Mr. Foo would receive two
spaces, too. (The solution could be using an extensive list of all
abbreviations such as Mr. etc. which can be followed by a capital
letter without starting a new sentence... But maybe there are
ambiguities, there, too?
And what about cases such as a proper name immediately followed by
ellipses? Ellipses are always three dots, they don't become four
when they end a sentence, usually the only way to tell if they do
is the case of the following letter...)

Anyway, a program written in C which uses ". " to tell where a
sentence finishes would be broken by using ". ".
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 21 '07 #16
On Fri, 21 Sep 2007 00:52:23 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>even in Usenet, where fixed-pitch fonts are the norm (presumably because
many people do more typing in word processors or other programs with
proportional fonts than in fixed-pitch programs such as text editors and
good Usenet clients).
Since we're off-topic anyway, I wonder if this is actually true? I
read Usenet in a proportional font simply because I find it easier to
read. I switch to a fixed font when someone posts code, or underlines
an non-obvious part of the previous sentence. I consider my Usenet
client to be a good one. In fact, the ability to switch fonts is one
of its good features :-)

--
Al Balmer
Sun City, AZ
Sep 21 '07 #17
In article <m1********************************@4ax.com>,
Al Balmer <al******@att.netwrote:
>On Fri, 21 Sep 2007 00:52:23 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>even in Usenet, where fixed-pitch fonts are the norm
>Since we're off-topic anyway, I wonder if this is actually true?
Who knows? Unless someone cares to do a statistical study of the
X-Newsreader headers of a large number of posts, and trusts that
the newsreaders are not lying about what program they are, and
the Newsreader name is correlated to ability to change fonts... then
the matter is essentially undecideable, potentially amenable only to
polls with bad "self-selection" bias.

And even if someone bothers to look up my X-Newsreader header and
notices that it cannot change fonts, they would miss the fact that I'm
almost always running the newsreader inside a terminal window and that
the terminal window can be configured to any font I want.

But if anyone cares: *I* only use fixed-width for reading Usenet.
I scan too many messages in which the formatting is important
(e.g., code) to make it worth flipping back and forth between
fonts.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Sep 21 '07 #18
Army1987 wrote, On 21/09/07 14:22:
On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
>>I'm trying to think up a way to link this to C, but not having a great deal
of success.
You could write a filter program in standard C to adjust your posts so
that they use two spaces.

It is less trivial than it seems, Mr. Foo would receive two
<snip difficulties>

I did not say that it was easy. Perhaps it would make good coursework
with extra marks being given for each of the difficulties the student
raises?
Anyway, a program written in C which uses ". " to tell where a
sentence finishes would be broken by using ". ".
I was not suggesting that a program should do that.
--
Flash Gordon
Sep 21 '07 #19
On Fri, 21 Sep 2007 18:55:42 +0100, Flash Gordon wrote:
Army1987 wrote, On 21/09/07 14:22:
>On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
>>>I'm trying to think up a way to link this to C, but not having a great deal
of success.
You could write a filter program in standard C to adjust your posts so
that they use two spaces.
[snip]
>Anyway, a program written in C which uses ". " to tell where a
sentence finishes would be broken by using ". ".

I was not suggesting that a program should do that.
Neither was I. It was just another example of a way to link this
to C. (Anyway, Emacs does do that.)
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

Sep 21 '07 #20
Army1987 wrote:
On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
.... snip ...
>
>You could write a filter program in standard C to adjust your posts so
that they use two spaces.

It is less trivial than it seems, Mr. Foo would receive two
spaces, too. (The solution could be using an extensive list of all
abbreviations such as Mr. etc. which can be followed by a capital
letter without starting a new sentence... But maybe there are
ambiguities, there, too?
And what about cases such as a proper name immediately followed by
ellipses? Ellipses are always three dots, they don't become four
when they end a sentence, usually the only way to tell if they do
is the case of the following letter...)

Anyway, a program written in C which uses ". " to tell where a
sentence finishes would be broken by using ". ".
Hey, I just wrote a sentence advising aslamhenny how to properly
punctuate English sentences; I didn't expect a major upheaval from
it. (And they don't end with ....).

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 21 '07 #21
Army1987 wrote:
>
On Thu, 20 Sep 2007 20:40:26 -0400, pete wrote:
I like this better:

printf("please key in any " xstr(LENGTH) " digits number :");
If you are indeed using printf, what's wrong with
printf("please key in any %d digits number :", (int)LENGTH)?
There's nothing wrong with that.
It'll continue to work if you define LENGTH in some more insane way.
But I already had the xstr() macro defined, so I used it.

--
pete
Sep 21 '07 #22
pete wrote:
Army1987 wrote:
>On Thu, 20 Sep 2007 20:40:26 -0400, pete wrote:
>>I like this better:

printf("please key in any " xstr(LENGTH) " digits number :");
If you are indeed using printf, what's wrong with
printf("please key in any %d digits number :", (int)LENGTH)?

There's nothing wrong with that.
>It'll continue to work if you define LENGTH in some more insane way.

But I already had the xstr() macro defined, so I used it.
Why go to all that trouble with macro when you could simply use an enum
for length?

--
Ian Collins.
Sep 21 '07 #23
Ian Collins wrote:
>
pete wrote:
Army1987 wrote:
On Thu, 20 Sep 2007 20:40:26 -0400, pete wrote:

I like this better:

printf("please key in any " xstr(LENGTH) " digits number :");
If you are indeed using printf, what's wrong with
printf("please key in any %d digits number :", (int)LENGTH)?
There's nothing wrong with that.
It'll continue to work if you define
LENGTH in some more insane way.
But I already had the xstr() macro defined, so I used it.
Why go to all that trouble with macro
when you could simply use an enum for length?
I needed the macro in this line:

rc = fscanf(stdin, "%" xstr(LENGTH) "[^\n]%*[^\n]", array);

which I snipped.

--
pete
Sep 21 '07 #24
In article <B9******************************@bt.comrj*@see.sig.invalid writes:
....
The two-space gap between sentences goes back to typewriting with a
fixed-pitch font.
In some places, not in other places.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Sep 22 '07 #25
Army1987 said:
On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
>>I'm trying to think up a way to link this to C, but not having a great
deal of success.

You could write a filter program in standard C to adjust your posts so
that they use two spaces.

It is less trivial than it seems, Mr. Foo would receive two
spaces, too.
This is possibly one reason for the development of open punctuation, in
which the punctuating of abbreviations was dropped completely, as in "Mr
Foo" rather than "Mr. Foo", "BBC" rather than "B.B.C.", etc.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 22 '07 #26
In article <pa****************************@NOSPAM.itArmy198 7 <ar******@NOSPAM.itwrites:
On Fri, 21 Sep 2007 08:32:56 +0100, Flash Gordon wrote:
I'm trying to think up a way to link this to C, but not having a great deal
of success.
You could write a filter program in standard C to adjust your posts so
that they use two spaces.

It is less trivial than it seems, Mr. Foo would receive two
spaces, too.
Not when Mr Heathfield is typing. In standard British, an abbreviation that
contains the last letter of the original word is not followed by a period. If
you had said "Prof. Foo" it would have been another matter.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Sep 22 '07 #27
In article <fd**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
In article <m1********************************@4ax.com>,
Al Balmer <al******@att.netwrote:
On Fri, 21 Sep 2007 00:52:23 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>even in Usenet, where fixed-pitch fonts are the norm
Since we're off-topic anyway, I wonder if this is actually true?

Who knows? Unless someone cares to do a statistical study of the
X-Newsreader headers of a large number of posts, and trusts that
the newsreaders are not lying about what program they are, and
the Newsreader name is correlated to ability to change fonts... then
the matter is essentially undecideable, potentially amenable only to
polls with bad "self-selection" bias.
And the newsreader actually does put in such a line (mine does not).
But if anyone cares: *I* only use fixed-width for reading Usenet.
I scan too many messages in which the formatting is important
(e.g., code) to make it worth flipping back and forth between
fonts.
Indeed.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Sep 22 '07 #28
In article <46*****************@news.xs4all.nlrl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
CBFalconer <cb********@yahoo.comwrote:
as********@yahoo.com wrote:
>
ceh my teacher is totally jerk........now he ask me to do in looping
humm.....i think maybe i can use for...nvm i will try to do on my
own...
i will ask if got any prob....
i think must use nested for...
What are all those dots for? Sentences are normally terminated
with a period (one dot) followed by two spaces.

One space, in civilised countries.
And there are also those uncivilised countries where it is no space after,
and those that require a space both before and after.

Quite some time ago I was amused that the editor of a series of reports
of the Argonne National Laboratory insisted on the Chicago style, meaning
that if a sentence ended with a quote the following terminator also should
be within the quote (whether it was part of the quote or not). Meaning
that for instance after the sentence:
the sign reads "stop."
you had no idea whether the period was on the sign or not. But it led to
a lot of confusion in a report about the Ada language. Sentences like:
for this we have the operator "+."
where the Ada name for the operator is "+".
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Sep 22 '07 #29
In article <Gf*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>This is possibly one reason for the development of open punctuation, in
which the punctuating of abbreviations was dropped completely, as in "Mr
Foo" rather than "Mr. Foo", "BBC" rather than "B.B.C.", etc.
"Mr Foo" has been a standard for a long time: many references
recommend only using a full stop when the word has been truncated at
the end, which does not apply in this case since the "r" or "Mr"
represents the last letter of "Mister". "Mr J. Foo" on the other hand
would be so written.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 22 '07 #30
Richard Tobin said:
In article <Gf*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>This is possibly one reason for the development of open punctuation, in
which the punctuating of abbreviations was dropped completely, as in "Mr
Foo" rather than "Mr. Foo", "BBC" rather than "B.B.C.", etc.

"Mr Foo" has been a standard for a long time: many references
recommend only using a full stop when the word has been truncated at
the end, which does not apply in this case since the "r" or "Mr"
represents the last letter of "Mister". "Mr J. Foo" on the other hand
would be so written.
Whilst I disagree, this is so far off-topic as to be practically antipodal,
so I don't plan to say anything further on the matter.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 22 '07 #31
In article <pY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>"Mr Foo" has been a standard for a long time; many references
recommend only using a full stop when the word has been truncated at
the end, which does not apply in this case since the "r" or "Mr"
represents the last letter of "Mister". "Mr J. Foo" on the other hand
would be so written.
>Whilst I disagree [...]
My description is readily verified by examination of books such as
Fowler's Modern English Usage (under "periods in abbreviations", I
think), but of course whether it is a *good* standard is a matter of
opinion.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 22 '07 #32
Richard Tobin wrote:
In article <pY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>"Mr Foo" has been a standard for a long time; many references
recommend only using a full stop when the word has been truncated at
the end, which does not apply in this case since the "r" or "Mr"
represents the last letter of "Mister". "Mr J. Foo" on the other hand
would be so written.
>Whilst I disagree [...]

My description is readily verified by examination of books such as
Fowler's Modern English Usage (under "periods in abbreviations", I
think), but of course whether it is a *good* standard is a matter of
opinion.

-- Richard
There isn't for English the equivalent of the Academie Francaise for
French, or the Royal Academy of Spain for spanish, etc? Is there a
standards body?

Sep 22 '07 #33
jacob navia wrote:
There isn't for English the equivalent of the Academie Francaise for
French, or the Royal Academy of Spain for spanish, etc? Is there a
standards body?
No.
An English dictionary reflects popular usage,
not the other way around.

--
pete
Sep 22 '07 #34
In article <46***********************@news.orange.fr>,
jacob navia <ja***@jacob.remcomp.frwrote:
>>>"Mr Foo" has been a standard for a long time; many references
>There isn't for English the equivalent of the Academie Francaise for
French, or the Royal Academy of Spain for spanish, etc? Is there a
standards body?
Certainly not. It's just one of several de facto standard ways of
punctuating English.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 22 '07 #35
jacob navia wrote:
Richard Tobin wrote:
>In article <pY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>>"Mr Foo" has been a standard for a long time; many references
recommend only using a full stop when the word has been truncated at
the end, which does not apply in this case since the "r" or "Mr"
represents the last letter of "Mister". "Mr J. Foo" on the other hand
would be so written.
>>Whilst I disagree [...]

My description is readily verified by examination of books such as
Fowler's Modern English Usage (under "periods in abbreviations", I
think), but of course whether it is a *good* standard is a matter of
opinion.

-- Richard

There isn't for English the equivalent of the Academie Francaise for
French, or the Royal Academy of Spain for spanish, etc? Is there a
standards body?
No. Proper English is defined by usage. How is the Academie doing? Did
they finally replace 'Parking' signs with 'Stationment des voitures'?
Hot Dog with Chien Chaud? Or is Franglais alive and well in Paris?

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Sep 22 '07 #36
On Sat, 22 Sep 2007 12:56:19 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>There isn't for English the equivalent of the Academie Francaise for
French, or the Royal Academy of Spain for spanish, etc? Is there a
standards body?
Yes and no.

If you work in the business of publishing, there are _exceptionally_
strict rules about punctuation and these are codified in a set of
widely accepted standard texts suc as The Chicago Manual of Style.
There are equivalents published by the OUP and CUP which are also
frequently regarded as axiomatic.

Also publishing houses have 'house rules' which must be adhered to,
'correct' or not. Similar to how one has to adopt house style when
moving jobs as a programmer. Gosh, topicality.

Sadly, when you move into the world of teaching, nowadays it is more
about SATS scores and fundraising than about actually using textbooks,
so...
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 22 '07 #37
"Dik T. Winter" <Di********@cwi.nlwrote:
Quite some time ago I was amused that the editor of a series of reports
of the Argonne National Laboratory insisted on the Chicago style, meaning
that if a sentence ended with a quote the following terminator also should
be within the quote (whether it was part of the quote or not). Meaning
that for instance after the sentence:
the sign reads "stop."
you had no idea whether the period was on the sign or not. But it led to
a lot of confusion in a report about the Ada language. Sentences like:
for this we have the operator "+."
where the Ada name for the operator is "+".
<http://www.catb.org/~esr/jargon/html/writing-style.html>, second
paragraph ff.

Richard
Sep 24 '07 #38
On Fri, 21 Sep 2007 16:28:29 +0000 (UTC), ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
>In article <m1********************************@4ax.com>,
Al Balmer <al******@att.netwrote:
>>On Fri, 21 Sep 2007 00:52:23 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>>even in Usenet, where fixed-pitch fonts are the norm
>>Since we're off-topic anyway, I wonder if this is actually true?

Who knows? Unless someone cares to do a statistical study of the
X-Newsreader headers of a large number of posts, and trusts that
the newsreaders are not lying about what program they are, and
the Newsreader name is correlated to ability to change fonts... then
the matter is essentially undecideable, potentially amenable only to
polls with bad "self-selection" bias.

And even if someone bothers to look up my X-Newsreader header and
notices that it cannot change fonts, they would miss the fact that I'm
almost always running the newsreader inside a terminal window and that
the terminal window can be configured to any font I want.

But if anyone cares: *I* only use fixed-width for reading Usenet.
I scan too many messages in which the formatting is important
(e.g., code) to make it worth flipping back and forth between
fonts.
Even in this newsgroup, the percentage of messages where formatting is
essential is very small, and a single keystroke switches. Even for
code, fixed-width isn't usually necessary.

--
Al Balmer
Sun City, AZ
Sep 24 '07 #39
CBFalconer <cb********@yahoo.comwrote:
Army1987 wrote:
Anyway, a program written in C which uses ". " to tell where a
sentence finishes would be broken by using ". ".

Hey, I just wrote a sentence advising aslamhenny how to properly
punctuate English sentences; ^
^
im
HTH; HAND.

Richard
Sep 25 '07 #40
In article <46****************@news.xs4all.nlrl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
"Dik T. Winter" <Di********@cwi.nlwrote:
Quite some time ago I was amused that the editor of a series of reports
of the Argonne National Laboratory insisted on the Chicago style, meaning
that if a sentence ended with a quote the following terminator also should
be within the quote (whether it was part of the quote or not). Meaning
that for instance after the sentence:
the sign reads "stop."
you had no idea whether the period was on the sign or not. But it led to
a lot of confusion in a report about the Ada language. Sentences like:
for this we have the operator "+."
where the Ada name for the operator is "+".

<http://www.catb.org/~esr/jargon/html/writing-style.html>, second
paragraph ff.
I was accustomed to British usage which (already quite a long time) does
in general not put the punctuation inside the quotes. Another nicety is
that in British usage quotation marks for speech can be either single or
double quotes, depending on the publisher. And for nested quotation it is
just the other way around.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Sep 27 '07 #41

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: TCMA | last post by:
I am looking for some tools to help me understand source code of a program written in C++ by someone else. Are there any non-commercial, open source C or C++ tools to reverse engineer C or C++...
3
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using...
0
by: Its_Me_SunnY | last post by:
hi friends... i'm a newbie in .net i had some queries in asp.net please help me out ( in ASP.NET USING VB.NET CODE) >how to get the list of terminals present in a network? >how 2 get the list of...
1
by: abbu | last post by:
Hi friends, Iam working on a C++ GUI. Gui is opening properly , but when i close it core dump happens i did a mdb on the file and got the below result. > $c...
2
knychtell
by: knychtell | last post by:
HI, can somebody help me figure out how can i get the value i inserted at the collection's property of a combobox appear in a listbox, what i wanted is like the RUN application, or the cmdprompt, i...
1
by: alibaaba | last post by:
HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does...
1
by: Dennis | last post by:
HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does...
2
by: oxiarius12985 | last post by:
Can you help me regarding this matter because I have some difficulties on how can I add a binary number using a java programs by means of array! heres the problem that I created will you plss.....
2
by: ocean001 | last post by:
hi all i am trying to retrieve some small data from my database to my PDA through ODBC, and i am using ODBC . can anyone help me. plsss
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.