472,805 Members | 958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 1381
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.