473,395 Members | 1,969 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,395 software developers and data experts.

Off Topic Posts

Has anyone computed the percentage of off topic posts in this group
using ANSI C?

usenet is a strange place

Jul 2 '06 #1
7 1414
Somebody posted:
Has anyone computed the percentage of off topic posts in this group

No.

using ANSI C?

ANSI C does not provide a facility for accessing Usenet, and thus one
cannot write a portable program for calculating such a percentage.
--

Frederick Gotham
Jul 2 '06 #2
Frederick Gotham (in Mk*******************@news.indigo.ie) said:

| one cannot write a portable program for calculating such a
| percentage.

Eh?

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

int main(int argc,char **argv)
{ long off_topic,posts;
if (argc < 3)
{ printf("Usage: %s <off_topic posts<total_posts>\n",*argv);
exit(EXIT_FAILURE);
}
off_topic = atol(*++argv);
posts = atol(*++argv);
if (!posts && !off_topic) puts("No traffic.");
else if (!posts) puts("You're kidding, right?");
else printf("%G%% of %ld posts were off topic.\n",
(100.0*off_topic)/posts,posts);
return 0;
}

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
Jul 2 '06 #3
Frederick Gotham wrote:
Somebody posted:
Has anyone computed the percentage of off topic posts in this group


No.

using ANSI C?


ANSI C does not provide a facility for accessing Usenet, and thus one
cannot write a portable program for calculating such a percentage.
--

Frederick Gotham
Hypothetically, if one were to run a news server, one could write a
program to analyze content. Such a program might look like this:

<code>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

enum {
BUFLEN = 131072,
MAXTOK = 4096
};

static int fgetline(char *, int, FILE *);
static int count(FILE *);

int
main(int argc, char *argv[])
{
FILE *fp;

if (argc < 2) {
fprintf(stderr, "usage: %s file \n", argv[0]);
return 2;
}

if ((fp = fopen(argv[1], "rt")) == NULL) {
fprintf(stderr, "can't open %s\n", argv[1]);
return 2;
}

return count(fp);
}
static int
count(FILE *fp)
{
char *tok[MAXTOK], *p;
char buf[BUFLEN];
int len, n, i, count = 0;
while ( (len = fgetline(buf, BUFLEN, fp)) 0) {
p = buf;
tok[0] = strtok(p, " ,\t\n");
for (n = 1; n < MAXTOK && (tok[n] = strtok(NULL, " ,\t\n"));
n++)
;

for (i =0; i < n; i++)
if (0 == strncasecmp(tok[i], "off topic"))
++count;
}
return count;
}

/* fgetline: read a line from fp, return length */
static int
fgetline(char *line, int max, FILE *fp)
{
if (fgets(line, max, fp) == NULL)
return 0;
else
return strlen(line);
}
</code>

Were such a person to pass in the file containing the comp.lang.c
cache, a rough estimate of the count of off topic posts could be
obtained.

Using the value the program returned, divided by the number of posts,
would give a percentage.

Please excuse the sloppy programming, as it was intended to be a proof
of concept, not an actual program.

I think the percentage would be above 80%
usenet is still a strange place

Jul 2 '06 #4
On Sun, 2 Jul 2006 13:03:29 -0500, "Morris Dovey" <mr*****@iedu.com>
wrote in comp.lang.c:
Frederick Gotham (in Mk*******************@news.indigo.ie) said:

| one cannot write a portable program for calculating such a
| percentage.

Eh?

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

int main(int argc,char **argv)
{ long off_topic,posts;
if (argc < 3)
{ printf("Usage: %s <off_topic posts<total_posts>\n",*argv);
exit(EXIT_FAILURE);
}
off_topic = atol(*++argv);
Undefined behavior if the value represented by argv [1] is outside the
range representable in a signed long.
posts = atol(*++argv);
Undefined behavior if the value represented by argv [2] is outside the
range representable in a signed long.
if (!posts && !off_topic) puts("No traffic.");
else if (!posts) puts("You're kidding, right?");
else printf("%G%% of %ld posts were off topic.\n",
(100.0*off_topic)/posts,posts);
return 0;
}
strtol() is much preferred, even for gag posts.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 2 '06 #5
Jack Klein (in 7s********************************@4ax.com) said:

| strtol() is much preferred, even for gag posts.

It's a value call. In my mind anyone who wastes time worrying over the
/percentage/ of OT posts (much less anyone who claims that such a
percentage can't be /calculated/ using C) richly deserves the whole
herd of nasal demons whizzing out one nostril, in the other, and
wreaking noisome mischief in their sinus cavities. [7.20.1] is my
friend in this instance - I just wish the demons were more reliable.
You /did/ notice that I managed to resist the nearly overpowering urge
to name one of the variables 'total'? ;->

<sighOk - everyone who doesn't care what the actual percentage is
should consider themselves invited to make that change before
discarding the program for being as worthless as it is - and everyone
who feels it's actually worth calculating the percentage is invited to
use it as is...

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
Jul 2 '06 #6
On Sun, 02 Jul 2006 17:26:04 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
Somebody posted:
Has anyone computed the percentage of off topic posts in this group
<snip>
using ANSI C?


ANSI C does not provide a facility for accessing Usenet, and thus one
cannot write a portable program for calculating such a percentage.
Standard C does not access _networks_, and particularly the Internet.
Usenet and more specifically netnews (which was originally only a
subset) predated the Internet, and although other transports have now
vanished AFAIK, it is defined and still operated so that each server
has a complete (modulo glitches) copy of all messages for however long
it chooses. And classically such servers kept these messages in simple
text files that not only can be read from C but easily so. Although I
haven't kept track of whether they still do, and I suspect not.

- David.Thompson1 at worldnet.att.net
Jul 10 '06 #7
Dave Thompson wrote:
On Sun, 02 Jul 2006 17:26:04 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
>Somebody posted:
>>Has anyone computed the percentage of off topic posts in this group
<snip>
>>using ANSI C?

ANSI C does not provide a facility for accessing Usenet, and thus one
cannot write a portable program for calculating such a percentage.

Standard C does not access _networks_, and particularly the Internet.
Usenet and more specifically netnews (which was originally only a
subset) predated the Internet, and although other transports have now
vanished AFAIK, it is defined and still operated so that each server
has a complete (modulo glitches) copy of all messages for however long
it chooses. And classically such servers kept these messages in simple
text files that not only can be read from C but easily so. Although I
haven't kept track of whether they still do, and I suspect not.
At least some local news servers, such as leafnode, still do this.
However, you still have the problem of how to read the directory which C
does not support.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jul 10 '06 #8

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

Similar topics

72
by: Wim Vanhoof | last post by:
Dear all, I would like to announce that the department of computer science of the University of Namur, Belgium, is seeking a post-doctoral researcher for a one-year fellowship in the area of ...
33
by: Chris Croughton | last post by:
I notice the real reason for not posting "off-topic" here is that the result will be a long thread on whether the matter is off-topic or not -- caused by the very people who claim that they don't...
8
by: fabio | last post by:
hi everybody i have a weird problem with my project, look at this: **************************************************** Debian:/progetto/PROGETTO$ ls -al server -rwsr-xr-x 1 root faz 372731...
20
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get a perl/asp/php variable into client-side js?...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why do some posts have <FAQENTRYin them ? -----------------------------------------------------------------------...
5
by: Michael Starberg | last post by:
cat, I wouldn't be worried about linq nor IDisposable. http://www.youtube.com/watch?v=MQ4vmSvCVbc Enjoy, and if you hate silly cats, at least the music is great! =) - Michael Starberg
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.