A list of puns related to "Brian Kernighan"
The magnanimous ...the irresistible ...the geek personified....and an incredible story-teller ...Brian.W.Kernighan!! Take a peek his commentary at **#**lca2022
I was not able to find anything online :(
Not so much of a question, just a fascination of their works. I haven't even read their full works. Yet I hear, read so much about them. All the time, more often than I can keep count. Also if any other personality I (programmers) should read. Many Thanks :)
Ah, a genuinely humble and a brilliant man,importantly one of my worshipped hero ,says it all. But also "Deglorifies" his all invaluable contributions to the computing industry,like, live in that special "league" ...
A salute!...You are awesome Brian!
If you could ask Brian Kernighan anything (of K&Rβs the C Programming Language, what would you ask him?
Iβm looking for interview questions. If your question is picked i will give credit and upload the interview here!
Hi! I'm learning from an old C book off ebay.
Brian W. Kernighan and Dennis M. Ritchie (Pub. 1978)
I'm on the Control Flow chapter, Exercise 3-3. Where a modification to the itoa functions is required to allow for the whole range range of integer values, the example on the page will fail on -2147483648 as it overflows when the sign is removed as part of the solution.
I have put a case into the function where it checks whether the input magnitude is greater than the max positive.
This seems messy to me, can anyone think of a way make the solution more elegant?
My code is below, this is my first time posting on this subreddit - I already use reddit so thought I'd give this a try rather than stackoverflow :)
Any other advice is welcome, it goes without saying that I'm a noob.
Cheers
/*
Code to test the itoa function.
This is my solultion to Exercise 3-3 of "The C Programming Language"
by Brian W. Kernighan and Dennis M. Ritchie.
*/
#include<stdio.h>
#include<stdlib.h>
#define MAX 100
#define LOWLIMIT -2147483648
#define HIGHLIMIT 2147483647
char s[MAX];
// Function declaration
int itoa(int n, char* s);
void reverse(char* s);
int main(void)
{
// Convert an integer to a string representation
for(int i = LOWLIMIT; i <= HIGHLIMIT; i++)
{
itoa(i, s);
puts(s);
}
return EXIT_SUCCESS;
}
// Integer argument is converted to a string representation
int itoa(int n, char* s)
{
int i, sign;
int max = 1;
int temp = 1;
// Left shift to get max possible size for input int
for(i=0 ; temp>0; i++)
{
max = temp;
temp = (temp << 1) + 1;
}
// Check if input is greater in magnitude than max value for positive
// integer. If so, then return max negative.
if(((sign = n) < 0) && ((-max) > n))
{
sprintf(s, "-2147483648");
return EXIT_SUCCESS;
} else if((sign = n) < 0)
{
n = -n;
}
i = 0;
// Find remainder of division by 10 and add to ASCII code offset for
// numeric symbols.
// While there is still another order of magnitude, repeat the loop.
do
{
s[i++] = n % 10 + '0';
} while((n /= 10) > 0);
// If the number was negative, then add a hyphen to the array
... keep reading on reddit β‘Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.