>>80
Most GNU programs aren't portable. Non-portability is one of the four main points of the definition of GNU quality:
1. Non-portability
2. Poor documentation
3. Non-standard behavior for standard utilities
4. GPL
/*
largest.c -- compares two integers, prints the largest and exit.
Copyright 2010 Kao Moji.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>;.
*/
>>95
1. It checks if the argc is 3, i.e. there 2 arguments(1st is the program name).
2. it uses strlen to compare if strings are inequal, and print the longest via ternary operator.
3. If it does not exit() it skips to last line(which means strings have equal length) and print one which strcmp selects as the largest(since strcmp compares each character sequentially) because 0<9 in ASCII any difference in sequence will make strcmp returns at the point where a character was different(larger in ASCII) and reports the difference as string1[y]<0>string2[x]. Where y/x are [0-9]
4. If the strings are completely equal, it returns string1.
Make me a C program that reads given two integers (no limits) and outputs the largest.
GNU MP is a portable library written in C for arbitrary precision arithmetic on integers, rational numbers, and floating-point numbers. It aims to provide the fastest possible arithmetic for all applications that need higher precision than is directly supported by the basic C types.
>>108
I do #include <config.h>, is that good enough?
Name:
Anonymous2013-01-19 23:17
/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.
Name:
Anonymous2013-09-29 18:42
kek'em trips
Name:
Anonymous2013-09-29 19:46
#include <ctype.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char a, b, *s, *t;
int max;
if (argc != 3) {
fprintf(stderr, "usage: %s x y\n", argv[0]);
return 1;
}
s = argv[1];
t = argv[2];
max = 0;
while (*s || *t) {
if (*s && !isdigit(*s)) {
fprintf(stderr, "not an integer: %s\n", argv[1]);
return 2;
}
if (*t && !isdigit(*t)) {
fprintf(stderr, "not an integer: %s\n", argv[2]);
return 3;
}
if (!*s)
max = 2;
else if (!*t)
max = 1;
else if (!max && *s < *t)
max = 2;
else if (!max && *s > *t)
max = 1;
if (*s)
s++;
if (*t)
t++;
}
if (max)
printf("%s\n", argv[max]);
return 0;
}
Name:
Anonymous2013-09-29 22:13
i = raw_input("Enter num 1: ")
ii = raw_input("Enter num 2: ")
if i < ii:
print "%r is larger" % i
else:
print "%r is larger" % ii