jephthah 1,888 Posting Maven

It doesn't seem like a topic of opinion though

well, apparently this one is.

hey, that reminds me, which is better: big endian or little endian? i seem to have forgotten...

John A commented: Big Endian. +18
jephthah 1,888 Posting Maven

okay, I'm going to stop arguing this because you guys are technically more precise than I am.

suffice to say, I use fgets(), and if i ever need to specifically search for end-of-file, i use feof() in conjunction with ferror(). this approach is generally supported by the GNU C manual, and i've found it to always be reliable.


.

jephthah 1,888 Posting Maven

as omnivores, humans are adapted to eating both meat and vegetables. our digestive track has enzymes evolved specifically for breaking down animal fat and protiens.

that said, we don't have to eat meat. so if you don't, good for you. but without a doubt it is more difficult and expensive to maintain a healthy diet that is lacking in animal protein.

in short, to each their own. if you don't want to eat animal meat, then don't. but I do, so if you don't like that.... too bad.

jephthah 1,888 Posting Maven

Hello, NickAx: it's so hard to take you seriously when you can't even spell "meat" correctly.

anyhow, Happy Eostre, everyone.


.

jephthah 1,888 Posting Maven

I'm not going to lie, it is pretty frustrating to see such varying opinions on a topic like this. No consensus?

it's a rare instance around here where you ever find a consensus.

as for using the EOF macro, personally i rarely ever look for the "end-of-file" marker when reading text files, i always parse results using fgets() and check the return value of that function. On the few occasions where i specifically need to look the end-of-file marker, i use the feof() and check the errno result from ferror().

Anecdotally, Ive heard of a number of situations where relying on the EOF macro results in unexpected behavior and problematic code, and I understand that there have been some bugs related to this macro.

at least one authority -- the GNU C Library Manual -- suggests that using EOF macro is not reccommended:

Since EOF is used to report both end of file and random errors, it's often better to use the feof function to check explicitly for end of file and ferror to check for errors.

this corresponds to my experience and anecdotal observations, so I'm content to leave it at that.

I'm not going to argue about it, because it's not a critical issue, but I'm also not going to use the EOF macro either. I'm going to continue to rely on the consistently reliable fgets() function, as I always have.

that's my opinion based on my limited professional experience. You can take …

jephthah 1,888 Posting Maven

WUT?

jephthah 1,888 Posting Maven

eh, okay.

i stand corrected.

jephthah 1,888 Posting Maven

what is that? Haiku?

jephthah 1,888 Posting Maven

I'm not saying you cant look for the end of file. what i said is this:

if you really feel you must look for the End of File marker, then use "feof()".

as for the EOF macro, it's not standardized. It can have different values depending on compiler. It can also be a catchall for various error codes. or ... not.

eyah, maybe it'll for your application, but if someone thinks that's "consistent", i'd like to see what they consider to be "inconsistent"

iamthwee commented: I'm sorry but this is wrong kiddo. -4
jephthah 1,888 Posting Maven

I find it useful on occasion to place a prototype in a function.

for what reasons, and in what context?

please elaborate.

jephthah 1,888 Posting Maven

A.D. is right. "fgets()" is the solution.

I guess I might as well contribute something to this community.

"contributing to the community" does not include doing some slacker's homework assignment for them. by doing so, you're circumventing the community's efforts to discourage laziness and plagiarism.

anyhow, relying on EOF is generally considered a poor way to read text files. it is not consistent across platforms, and you'll eventually get burned.

http://www.gnu.org/software/libtool/manual/libc/EOF-and-Errors.html

if you really feel you must look for the End of File marker, then use "feof()".


.

jephthah 1,888 Posting Maven

Until you translate that to C we can't move any further with that code.

why, exactly, are we reinventing the wheel?

i'm trying to locate my motivation for "moving further", and not having much luck....

jephthah 1,888 Posting Maven

can someone give me this programming code?

no.

jephthah 1,888 Posting Maven

... retracting ...

jephthah 1,888 Posting Maven

i work in an FDA regulated industry. ... it's all groovy when a company is flying under the radar, but let me tell you, once the FDA gets a company's number ... they are a HUGE threat. more than you know.

though, on second thought .... OSHA would probably be a more appropriate regulatory body, given the type of grabassery that i suspect was going on in this case.

.

jephthah 1,888 Posting Maven

mental illness : a game that's fun for the whole family!

:)

jephthah 1,888 Posting Maven

i want a t-shirt

:(

jephthah 1,888 Posting Maven

Can someone give me the code for this???

come on, man, you've been here long enough now to know better than that

jephthah 1,888 Posting Maven

i believe you will want to call the maqr() function after you've allocated the memory sizes.

also, remember to always use "free" after you're done with the allocated arrays.

jephthah 1,888 Posting Maven

AHA! something happened!

I have been promoted to apprentice Shark.

w00t

jephthah 1,888 Posting Maven

because you cant use variables to declare sizes of arrays. why do you feel that you need to dynamically size your arrays? what's wrong with hard coding them?

if you insist on dynamic memory allocation, then you need to use "malloc" . but i really suggest that you don't go there.

jephthah 1,888 Posting Maven

...posts?

i'm gonna find out.

jephthah 1,888 Posting Maven

don't go yet.... we still need to argue about winsock vs. sockets!

jephthah 1,888 Posting Maven

i sort of misread the title and thought that you were going to tell us about your erotic fantasies.

jephthah 1,888 Posting Maven
jephthah 1,888 Posting Maven

eh, i feel like i'm trapped in an Escher painting.


anyhow, metal_butterfly, there could be any number of reasons why your server is refusing the connection from your client

http://technet.microsoft.com/en-us/library/cc975854.aspx

jephthah 1,888 Posting Maven

^ egads, that tops my slaughterhouse story. i worked on the automation systems for a pig processing plant, but we only worked on weekends when it was shut down.

seriously though, that sounds like it might have been an intentional safety violation on the operator's part, to run a saw so close to an unqualified person on the line. I can see how those guys would get a kick out of watching some whitecollar techie get freaked out.

depending on the circumstances, i might have made a lot of noise about that. threatening to file a report with the FDA would have got management's attention real quick.

jephthah 1,888 Posting Maven

hey, no worries, usman2k4u... i can totally help you out with this code.

here is the start

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

int main()
{
     // declare local variables here

     // insert body of code here

     return 0;
}

you fill in the rest.

then when you can formulate a real question, come on back and we'll match you up with a real answer.

.

jephthah 1,888 Posting Maven

Is it assumed that once a macro is defined, it is equal to 1 in a C program

no, it is not. normally you always specify a value to the identifier you want to #define .

if you dont specify a value, it is the preprocessor will replace the identifiers with blank space or an empty string... not a "1".

the only time you should not specify a value, is when you're using the identifier to enable conditional compilation like i described with the #ifdef / #endif pairs.

jephthah 1,888 Posting Maven

no you can't do that. because the BOOL could be defined as value zero. or seventyelevenbillion.

or, worse yet, BOOL could not be defined at all. then what would happen to your conditional evaluation???

so, i believe the thing you're looking for is the preprocessor directive, "#ifdef"... use it like so:

#ifdef BOOL
   // do stuff here
#endif

#ifndef BOOL
   // do different stuff here
#endif

the code that you write between the #ifdef and #endif (or #ifndef and #endif) will only be compiled if the statement evaluates as TRUE. otherwise it won't ever be compiled, much less run.

jephthah 1,888 Posting Maven

You're pathetic.

did i really piss in your cheerios, mate? is it so bad you're reduced to foaming about the mouth uttering unqualified personal attacks?

John A. rightly pointed out that a termios or ncurses solution would not be any better than your conio solution, just from the other direction.... and perhaps you missed it, but my attempt at self deprecating humor conceded the point. And your followup post about conditional compilation was right on the money, so it's obvious you "get it"

come on now, let's be friends, nucleon, you and me. we can go bowling or something :P


.

jephthah 1,888 Posting Maven

hmm. i thought my post was calm and to the point. the inappropriate use of and reliance on globals is a habit that is reinforced by laziness and/or a 'get-r-dun' attitude.

i understand your position: you think that at this point it's not worth the time to undo what he's already done. presumably, he'll learn to not learn globals some future point.

but what i'm saying is that I think it IS worth the time, right now -- otherwise, the time never gets taken. and the habit steadily becomes more firmly entrenched.

i'm just expressing my opinion based on my experience. i wasnt attacking you; don't take everything so personal.


.

Salem commented: "Who has time? But then if we never *take* time, how can we have time?" - Merovingian +29
jephthah 1,888 Posting Maven

i heard he made $Skazillions

jephthah 1,888 Posting Maven

At this stage I wouldn't bother de-globalizing your variables

when would you suggest he start "de-globalizing" his design process?

the inappropriate use of globals (ie 98% of the time) is one of the major systemic contributors to buggy, unmaintainable code.

remove those globals now and get the pain over with before it devlops into a chronic disability.

jephthah 1,888 Posting Maven

And you can write a termios.h solution that will be broken on every non-POSIX system. What's your point?

that my indignant self-righteousness only flows in one direction: from GNU/GPL and against MSFT.

it ain't right, but i can still sleep most nights.

Aia commented: Hahaha! +14
jephthah 1,888 Posting Maven

conio.h (if available to you) has the function _getch() which is unbuffered and does not echo the character read.

i wish i could give you half a cookie, for your halfassed solution.

sure you can write a program with conio.h, but it will be broken on most every non-microsoft systems.

conio.h is a header file used in old MS-DOS compilers to create text user interfaces, however, it is not part of the C programming language, the C standard library, ISO C or required by POSIX. ... Most C compilers that target UNIX and Linux do not have this header and do not supply the concomitant library functions.

-- wikipedia

jephthah 1,888 Posting Maven

^ you should try going downtown to the shelters and arguing with the schizophrenics.

no, really. it'll be fun.

jephthah 1,888 Posting Maven

sorry, folks, i didn't mean to come off sounding like such a dick.

truth is: i still have issues, and i'm exceedingly frustrated by this subject

especially by the paradoxical fact that i live in the most technologically-advanced country, which seems to be always on the verge of being taken over by a bunch of superstitions chicken bone shakers.

it probably didnt help that i grew up and spent a large part of my adult life in the U.S. South. or that I've got a bunch of fundamentalist anti-intellectuals in my family.

:(

ddanbe commented: superstitious chicken bone shackers, could be the title of the next great song! +4
jephthah 1,888 Posting Maven

I have tried your solution but I can't solve it .(because i have no much more experience in C ). Please Can anyone write code?.. Thanks

we'll help you but you've got to show some effort. you cant just come here asking someone to do all your work for you.

surely you've written some code already? post it here, then we'll help.

if you havent written anything yet, you need to get busy. I'll give you a place start:

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

int main ()
{
    //declare your variables first


    //then write the body of your code




    return 0;
}
jephthah 1,888 Posting Maven

Well, I'm speaking of late 80's. They were borderline classics at that point, but still much more common than they are these days. I'm only 38 :P

ah, we're the same, then.

but yeah, they were kind of uncommon then, now they're pretty rare i guess.

Lol I drove a '91 Mazda...

hey, that's a borderline classic car, now!


.

jephthah 1,888 Posting Maven

um, well they were old even back when i was in HS ...

kids still have those old muscle cars today.

jephthah 1,888 Posting Maven

i see what you're saying. i probably said the same thing too.

now i think: nothing new, not convincing anyone, preaching to the choir.... yep.... circle jerk.

jephthah 1,888 Posting Maven

ehh... i was the kid who should have been in honors, but bought into that whole 'cool to be stupid' clique.... and eventually assimilated.

yeah: smoking, metal shirts... i wasnt cool enough for a chevelle. i just had a '74 Nova. With "Megadeth" logo painted on it. it was the "dethmobile" :)

geez.

how did i survive?

jephthah 1,888 Posting Maven

If that were the case then the solution would be easy -- get the world banks to forgive the debt, mush like USA did WWII debt by many nations.

well... it IS the case, and it's apparantly NOT easy.

for one thing it's not one nation forgiving the debt of another.... it's multinational banking organizations who have to answer to powerful investors across the globe.

perhaps you have an inside angle?

jephthah 1,888 Posting Maven

i was "Most Likely to be Dead or Incarcerated at 25"

jephthah 1,888 Posting Maven

internet evolution/ID "debates" are always just a big circle jerk. the only difference is sometimes one side has the bigger circle, sometimes its the other.

you haven't uncovered anything new. i remember the heyday of TAMU's Internet Infidels, talk.origins USENET, and Church of the Subgenius. I, too, thought i was quite clever, but 15 years later I see nothing has changed.

what I'm saying is, you might as well go debate abortion at a Catholic Grandmother's Quilting Bee. Because your persuasive use of logic and reason and scientific methods, will have you just as likely to convince someone that their position is indeed wrong, and that they need to come over to your side.

jephthah 1,888 Posting Maven

Godspeed, young cadet. A tragic loss 'tis ours, how such we never knew thee.

jephthah 1,888 Posting Maven

it also doesnt help that their nations have national debts dating back to the 1960s that they can just barely pay the interest on much less hit the principal.

so much of their GDP goes to paying the world banks' interest, they cant ever get out of poverty long enough to oust the military juntas and tribal dictators.

jephthah 1,888 Posting Maven

the best way to understand is to spend a lot of time making mistakes.

just start hacking away at a solution. understanding will come later. meanwhile, figure out how to use those three commands i mentioned (any online reference) and that's about all you need.

jephthah 1,888 Posting Maven

oops. my bad. i was thinking about a structure of arrays, when he (and you) are clearly talking about an array of structs

but if i rewrite his code can i still pretend I know what I'm talking about? :D

struct Crypt
{
   char english[26];
   char code;
   int count[26];
};
void analyze(struct Crypt[]);

void main (void)
{
   struct Crypt Key;
   analyze(&Key);
}

void analyze(struct Crypt key[])
{ int i=0;  /*just a sample of the text*/
   while(i!=26)
   {
      key->english[i]=(i+65);
      printf("%d%c  ", key->count[i],key->english[i]);
      i++;
   }
}
John A commented: Using void main? tsk, tsk :P -4
Aia commented: ;) +15