printf headache

O

Old Wolf

Old said:
He may be thinking of the 'reverse Euclidean algorithm', ie.
once you have determined that g = gcd(a,b) via the Euclidean
algorithm, you can then backtrack through the steps to find
x,y such that g = ax + by.

OT, but interesting: note that this lets us solve any
equation such as:

23x = 1 (mod 240)

where the 23 and the 240 are coprime (because if two
numbers are coprime then 1 is their g.c.d.).

This has an application in public key cryptography, where
once you have picked a public key 'e', the private key
'd' is specified by:

ed = 1 (mod phi(n))

(and 'e' was chosen such that e and phi(n) are coprime).
 
A

Al Balmer

Sorry, Al, that my little hissy fit was directed at you. I was fresh out of
a fisticuffs. My claim is that % followed by l (ell) violates the sentence
preceding Table B-1. Obviously, the Standard is relevant, and K&R talk
pedagogical. I think the sentence would be correct if it said 'if the
character after the % , and after all the optional things above, is not one
of the below characters, the behavior is undefined.' Not exactly
Shakespeare. Joe

I'm not going to quote it again, but if you reread it, you'll find
that I was not only agreeing with you, but offering proof, since I
*did* have a copy of K&R at hand.
 
M

Michael Wojcik

Note the first line of main.

Though this does demonstrate one problem with putting function
declarations at block scope: even experienced programmers may miss
them when reading the code, because it's common to put them at
file scope.

And it's common to put them at file scope in part because they can't
be placed at block scope if they include the "static" sc-specifier,
which is another problem with putting them at block scope.

In sum: Joe, don't put function declarations at block scope. Put
them at file scope, thus:

#include <stdio.h>

unsigned long gcd(unsigned long m, unsigned long n);

int main(void)
{

--
Michael Wojcik (e-mail address removed)

She felt increasingly (vision or nightmare?) that, though people are
important, the relations between them are not, and that in particular
too much fuss has been made over marriage; centuries of carnal
embracement, yet man is no nearer to understanding man. -- E M Forster
 
J

Joe Smith

Michael Wojcik said:
Though this does demonstrate one problem with putting function
declarations at block scope: even experienced programmers may miss
them when reading the code, because it's common to put them at
file scope.

And it's common to put them at file scope in part because they can't
be placed at block scope if they include the "static" sc-specifier,
which is another problem with putting them at block scope.

In sum: Joe, don't put function declarations at block scope. Put
them at file scope, thus:

#include <stdio.h>

unsigned long gcd(unsigned long m, unsigned long n);

int main(void)
{

God, I knew that. They pulled five staples out of my head last year.
Cbfalconer goes nuts every time he sees it and for obvious reasons. One of
the best poems I ever wrote was about a fella named 'Wojcik'. If just so
happens to rhyme with 'fat chick' and of course "paycheck." Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,517
Latest member
TashaLzw39

Latest Threads

Top