jephthah 1,888 Posting Maven

the beauty about internships is they don't expect you to know a whole lot, and will teach you what to do.

i'd be pretty stoked if i were you. this is a great opportunity.

jephthah 1,888 Posting Maven

i dont think so.

Note that the first group of octal numbers converts to the hex value 0xC3D4. in other words, your first two octets (8-bit values) are 0xC3 and 0xD4

if it were in the proper order, the very first octet would correctly indicate that the IP Version is "4" (or "6") those are the only possibilites. your packet says the IP Version is "C" (ie, 12). furthermore, the minimum valid IHL is 5. in your example the IHL is "3". both of these are invalid.

now look at the IP specification, and see for yourself how this does not make sense:

Internet Protocol

                           3.  SPECIFICATION

3.1.  Internet Header Format

  A summary of the contents of the internet header follows:

    0                   1                   2                   3   
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Time to Live |    Protocol   |         Header Checksum       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Source Address                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Destination Address                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Options                    |    Padding    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Example Internet Datagram Header
jephthah 1,888 Posting Maven

this has only been solved about 100 times in the past year or two.

i think we're all tired of this one.

why dont you do a nominal search and find one of the many full solutions available?

jonsca commented: Amen +4
jephthah 1,888 Posting Maven

yeah, and don't forget to take your vitamins.


now as for printing an array, just use a loop:

for (i=0; i<NUM_ROWS; i++)
{
    for(j=0; j<NUM_COLS, j++)
    {
        printf("%c", current_board[i][j]);
    }
    printf("\n");
}
jephthah 1,888 Posting Maven

Do you want all of Dave's threads to be closed?

of course not.

and i completely changed my mind about requesting this be closed. It was a misguided idea, a kneejerk reaction to the thought of spammers bumping this thread every couple weeks along with the assorted retards popping in and saying stupid shit.

but dave, i'm sure, would be more interested in keeping dialogue open. at any rate, this is a huge thread and even if it is bumped by dumbasses and spammers from time to time, it will keep his memory alive.

though i didn't agree with most of his politics, he was a class act. I only knew him from the forums, but i miss him.

.

jephthah 1,888 Posting Maven

Ive searched the web but found little help.

O RLY?

jephthah 1,888 Posting Maven

ID3 are far more commonly used for music files than APE, but it depends on who tagged the file. theres no way to enforce which tag someone uses. so, you can just look for one tag type, or you can look for multiple.

depends on how versatile you want your program to be and how much extra work you want to do.

overall, it's not hard. just look for the IDE specific tags at the end of the file. or APE tags at the front.

either they are there, or they aren't.

you know how the tags are formatted and where they are located (generally) by their specifications. it's really pretty cut and dried.


.

kvprajapati commented: Informative. +9
jephthah 1,888 Posting Maven

Yesterday, I saw Titanic again because I love to watch it again and again.
Its my favourite movie.

that's because you suck at life.

jephthah 1,888 Posting Maven

What you calling 'baiting' I call a harmless joke. If this is considered 'baiting' then I think you should remove a lot more posts all over the site. It isn't a big deal, just saying. Also consider how the OP fired right back and I took it in stride. But I can see that you haven't bothered to edit his comment, just mine.

stfu noob.

jephthah 1,888 Posting Maven

threads like this bring the lulz and keep me coming back. :)

i didn't know n00bs couldn't create tags... what's the threshold? and why don't we have the same thing for Code Snippets?

Actually, what I really want to see is some kind of minimum/threshold for allowing signature links.

.

Salem commented: I want the minimum threshold for being allowed to post to be set to 10 posts (that should keep most of the dolts out) +0
jephthah 1,888 Posting Maven

okay, i'm suspicious about this example IP header. for instance, the first octet is supposed to contain the IP version (either 4 or 6) and the IP header length (at least 5, but probably not more than 8 or 10 or so...)

i dont see what appears to be a valid first octet anywhere in this code. I dont see what looks to be a "typical" valid IP destination or IP source address either, although this could be made up to be something unusual. i would have to see more about the assignment to understand if your instructor has constructed this IP packet in some sort of unusual manner, because it doesn't make much sense to me.

if you want to see what i'm seeing compile this code to convert the octal packet to a hexadecimal packet. if anything this will get you started.

/* This code is 'quick and dirty' and performs ZERO error checking.
   It is not suitable for commercial or academic use.  
   it is only supplied here as a concept example  */


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

int main(int argc, char **argv)
{
    FILE *fp;
    char string[80], *ptr, *doubleOctet;
    int do_val;
       
    fp = fopen(argv[1], "r");
    
    while((fgets(string, sizeof(string), fp)) != NULL)
    {
        doubleOctet = strtok(string, " ");
        printf("0x0000");
        do {
            do_val = strtol(doubleOctet, &ptr, 8);
            printf("%04X ", do_val);
        } while ((doubleOctet = strtok(NULL, " ")) != NULL);
        printf("\n");
    }
    
    fclose(fp);
       
    return 0;    
}

I compile the code using gcc, then run the code by …

jephthah 1,888 Posting Maven

the problem here is that an array index is increasing beyond the boundaries of your array size, and trying to access memory that has not been allocated.

fix this

for (index=1; index < len; index++) {

.

jephthah 1,888 Posting Maven

declare your variables at the top of main()... before your while loop.

declare your array 'home' size properly.

jephthah 1,888 Posting Maven

initialize a float with value zero.
begin a while loop to take character input, and break on newline entered.
in the body of the while loop you will :
--- check if decimal point is entered. if so, keep track of this fact, and continue to get next character
--- convert numeric char to value
--- if value is prior to decimal point, multiply total float value by 10, then add the numeric value
--- if after the decimal point, divide the numeric value by incrementing powers of 10, add the result to the total float value

you will need to perform error checking at all inputs, to ensure no invalid characters are entered.

jephthah 1,888 Posting Maven

Daniweb: Thanks for sharing!
______

Spam link here.


.

Salem commented: ROFL +0
Nick Evan commented: Excellent +0
jephthah 1,888 Posting Maven

sadly there are a LOT of professional marketeers here. They're all in the business of generating accounts for their spambots to flood the forums with link spam.
It's no doubt well known by now that Daniweb endorses link spam in signatures and won't do anything about it, so ever more will flock here knowing their messages won't be deleted and will turn up on Google searches for years to come.

yeah, i've been wondering about that, why that is.

it's kind of disturbing actually, and i've been avoiding thinking about the whole issue and it's ramifications. i

i enjoy participating in the forum of my programming-language-of-choice... but the fact that this whole website is really becoming such a spam relay station makes me reconsider whether i should continue to participate here at all anymore.

like, for instance, there's this rule about putting your email or website contact info in your post. it will get snipped and repeats will presumably get you warnings. Yet someone can fill their signature with emails and contact info, and that's perfectly okay?

what kind of hypocritical bullshit is that?

jephthah 1,888 Posting Maven

you can certainly password-protect files -- and even entire directories.... the easiest way is called "setting permissions" on *nix and windows has an equivalent, and the password protection is your account login. of course if you share an account the issue is moot. you also have no protection against the superuser or root (windows admin).

a more thorough but expensive solution (in time and money) is to get 3rd party encryption software to password-protect entire files and directories. This will stop everyone, up to and including industrial or government forensics agencies if you really want to pay for it.

but here's another, far more likely, possibility: nobody gives a flip about your C-programming homework. so forget about it.


.

jephthah 1,888 Posting Maven

the entire thread, starting from the very first snippet by OP, is crap.

code snippets should not be allowed to be created by anyone with less than 100 posts.

jephthah 1,888 Posting Maven

what i'm wondering is why a marketing student would think that professional marketers hang out in an "IT Professionals Lounge"

I mean, marketers dont have a technical bone in their body. they obviously wouldn't have any idea about a forum .. for ... technical ....

oh. wait. i get it now.

jephthah 1,888 Posting Maven

I think he meant C Sharp 101

because that would make MUCH more sense

:icon_rolleyes:

jephthah 1,888 Posting Maven

i am kinda lost too can u change my code which is up and make it correct cause i am confused....

that's not how it works here

Fbody commented: Can I get an AMEN! :) +1
jephthah 1,888 Posting Maven

I saw the tip posted by a couple of the senior members here. I have started doing equality comparisons this way as a way of reducing program errors.

Basically, it makes the compiler check that you aren't attempting assignment instead of an equality comparison. If you accidentally use assignment, the compiler will flag it as a syntax error because you are attempting to modify a constant.

I had the assignment vs. equality thing bite me just the other day because I didn't do this.

hmm. i'd never heard that before, but i guess it makes some sense... at least theres a legitimate reason. i thought people were doing it just to be clever.

jephthah 1,888 Posting Maven

first off, get rid of "Fast Learner, Good Listener, Self Starter, Self-Motivated". that is all bullshit. every student in the world puts that crap up, and it means zilch other than to waste space.

the two jobs you had at school dont belong under education, they belong under jobs. if you want to put more in education, summarize a few brief points about 1 or 2 senior level classes (design!) where you accomplished something important and RELEVANT to the job you're applying for

cut out most of the verbiage in your main webdev job description. bring it down to a few bullteted or otherwise highlighted points about WHAT YOU DID, how you did it, and what benefit it provided. short and sweet. resume reviewers look at sometimes hundreds of resumes a day, and they're likely only to read 1/3 of your total content. go ahead and get rid of that 2/3 filler now.

and yeah, say "entered and maintained classified data according to established protocol" or some such.... none of that "if i tole ya i has ta kill ya" crap. :icon_rolleyes: that might impress your little sister, but not anyone in IT.


.

jephthah 1,888 Posting Maven

its just assigning the first "num" value (the index i == 0 ) to the control variable, "minVal"... you got to start somewhere, right?

but I've got to take exception to if (0 == i) It is logically correct, but considered poor style.

there's no reason why you should obfuscate your code and decrease it's readability by reversing the standard left->right read direction of the conditional.

the only effect is to startle half the people who read your code, and thoroughly confuse a smaller but significant fraction.


.

jephthah 1,888 Posting Maven

Oh....

:(

What a sad loss. I will miss him. I liked him very much, and benefited many times from his knowledge,.

I regret my getting prickly towards him in some political discussions. He was never anything but polite and just loved the debate. I wish now I was better able to see past the superficial and had better known the man, the husband, the father ... the person ... behind the screen name.

Deepest regards and sympathies to his family. Dave was well liked and widely respected.

Long time no C

Indeed. Godspeed, man.

.

jephthah 1,888 Posting Maven

okay, i've changed my mind. I would buy a daniweb shirt that said either

"Banned" or "givemetehcodez"

cause that brings teh funnay.

.

jephthah 1,888 Posting Maven

Title: Strange bug with gets()

Answer: the "gets" function *IS* a bug. kill it before it breeds.

Aia commented: Read the title. Thought the same. +8
jephthah 1,888 Posting Maven

your variables.c file should NOT have a "main()" function. your variables.c file should have ONLY the implementation of the three functions prototyped in variables.h.

the two files, variables.c and variables.h are a pair. the .h declares the prototypes, the .c defines the implementation. you may not be used to seeing .h files, they are not strictly necessary. but you will find they are increasingly important as your projects get bigger and more files are involved.

the "dictionary_test" file is the file that has the "main()" routine. this is the entry point when the program is executed. this file will have the "#include variables.h" which links the functions compiled from the "variables.c" that you will write, so that those functions can be used in the program.

your job now is to write these three functions, put them in the "variables.c" file, and write them strictly according to the prototypes declared in "variables.h"

here is the start of your variables.c file:

#include <stdio.h>


void set_variable (const char* name, double value)
{


    return;
}
double variable_value(const char* name)
{


    return 0;
}

void display_variables()
{


    return;
}

your project will now compile without errors. it won't do anything, and likely may crash with a runtime error until you actually write the functions to do what is expected, but it will compile.

try to understand this general method. if you ever get a job programming, this is likely how you will be assigned work to do: to write …

jephthah 1,888 Posting Maven

well, those can be excused becasue the poster thought they were posting a question correctly.

the worst is these code snippet "programs" that with deprecated Turbo C libraries: they don't compile, they're so horribly written they're unreadable, and even if you take out the non-standard stuff, they're still broken and don't do what they're supposed to do.


.

jephthah 1,888 Posting Maven

well, okay...... but we waited almost 3 years for that?

jephthah 1,888 Posting Maven

sorry it took me so long to get back to this.. You should learn how to use strtol(). each time you call strtol, it finds the first numeric value in a string, converts it to a long int and returns it. it sets the pointer argument to the very next character in that string

if non-numeric characters (alpha or symbols) are found, zero is returned as the value and the pointer continues to point at the start of the string that was being looked at. this indicates that it failed to find a numeric in the string.

(Note, strtol() will ignore and skip over any whitespace found before a value. whitespace after an int value indicates the end of that value.)

i'm going to give you this snippet because i think seeing an example like this in action is really instructive.

// ... set up your variables

fgets(single_line, sizeof(single_line), stdin)

numberOfEntries = strtol(single_line, &ptr, 10)

for (i = 0; i < numberOfEntries ; i++)

   value[i] = strtol(ptr, &ptr, 10) 

// ... do the rest

some people may think i'm giving you too much, so you're going to need to figure out from here how to set it up properly within the context of your program.

Be advised this performs no error checking whatsoever; erroneous input may cause this code to behave quite badly. all good code should have error checking.

for reference:
fgets()
strtol()


.

jephthah 1,888 Posting Maven

I have a fleet of cars -- it's a Ford.
I have a pride of lions -- his name is Leo

http://icanhascheezburger.files.wordpress.com/2007/05/jesus_christ_its_a_lion.jpg

Salem commented: ICHC FTW :) +20
WaltP commented: And the lion's wearing socks! +11
jephthah 1,888 Posting Maven

Hi. first a comment, then the answer:

the reason why it took 14 hours for someone to reply, is that your code is nearly unreadable. yes, you used code blocks and yes you used indentations, and that's a great start. thank you.

but your lack of a consistent style of bracketing, lack of a consistent style of indentation, and a seeming aversion to using whitespace or giving your variables meaningful names, well, all of that makes it very hard to understand what you're doing.

and if you think this is a pedantic criticism, it's not. unreadable code is worthless in the industry, even if it "works". companies lose millions of dollars and people lose jobs because code is not intelligible to others.

so, i felt sorry for you not getting an answer, but i had to fix your code to make it readable before i could spot the the (very simple) error.

here's your newly formatted code. merry christmas:

#include <stdio.h>
#include <time.h>

int main(void)
{

    int x, y[12][12] = {{0},{0}};
    int roll, move;

    int i, j;               // okay, these are loop indexes
    int a, b, c, d;         // but these are meaningless names here

    srand(time(NULL));

    a=5;
    b=5;
    y[5][5]=003;         // "magic numbers" are not good programming


    {  // <--- WHY IS THIS BRACKET HERE?

        for(i=1; i<=10;i++)
        {
            y[1][i] = 2;          // more magic numbers
            if(i==5 || i==6)      // okay, it just gets worse from here.
                y[1][i] = 0;      // so no more comments about …
tux4life commented: Nice :) +8
jephthah 1,888 Posting Maven

Line 22 should be rad = input*pi/180; (since pi rad = 180 degrees)

(also cos(2*pi) = 1 not 2)

pi / 180 is what you'd use if you were making the conversion from degrees. i don't think he is doing that, his input is just in radians, actually the input is the multiplier, like 1/4 * PI or 2 * PI, etc.

and yes, cos(2 * PI) = 1

using 6 taylor series terms will give you good values for all angles between -PI and +PI radians. however if you try to do 2*PI, you will need more series terms and the factorial will be too large for a 32-bit integer. any angles greater magnitude than +/- PI will have your series summation become increasingly inaccurate.

here's your corrected code. i think your problem was that you weren't alternately subtracting and adding the terms correctly. i cleaned up the indentation and teh debug output so it's more clear what's going on.

#include <stdio.h>

#define PI                3.14159   // make PI a #defined value, not a variable
#define TOTAL_SERIES      6         // the number of taylor series terms to use

#define DEBUG

float cosi(float x);
int factorial(int x);

main()
{
    /* Declarations */
    float input;
    double rad;
    double cosine;

    /* Ask user for an angle (in radians) */
    printf("\nEnter the angle multiplier in rads (don't include pi): ");

    /* While user has more input */
    while ( scanf("%f", &input) > 0)
    {
        /* Convert input into its decimal form …
jephthah 1,888 Posting Maven

i'm curious what cities you visited. america is a diverse place, i think you may have been in a relatively conservative area of whatever city you went to. For example, i live in the city of Seattle. i would contradict some of your observations with anecdotes of my daily life.

-- there is no Wal-Mart in the city limits of Seattle. they've been zoned out, we don't want them here. you have to travel pretty far to the outskirts, 20+ miles, 1/2 hour drive time to get to one. my wife gets me to go there maybe once a year.

-- our freeways are big, and yet traffic congestion is a constant problem in every metro area. we keep building bigger freeways, but its never big enough. most of the cars on the road are occupied by a single-driver. we seriously need to reconsider transportation alternatives.

-- cyber crime, id theft, financial account breakins are highest in seattle than every other city (NY and SF are up there with us). it's blamed on the widespread practice of providing "free (unsecured) wifi". something does need to be done.

-- mcdonalds sucks. i dont know if it's the symptom or the cause, but "big quick and greasy" represents what's wrong with america. and i'm as guilty as anyone. a big mac sounds yummy right now :(

-- guns are a divisive issue. there are strong opinions on both sides.

-- people here LOVE to talk about …

lllllIllIlllI commented: Hahaha good points :) +0
jephthah 1,888 Posting Maven

I'll be brutally honest with you: you don't stand a chance.
Most companies won't hire anyone without experience when they're over say 25 years old. Too expensive.
And by the time you get your degree, you'll be 35+, at that age it's hard to get any job in IT at all.

i can't say how strongly i disagree with this, but let me take a stab at it:

that is pure bullshit.

getting a job is all about aptitude and -- most especially -- enthusiasm for the company and perseverance in applying.

yeh, maybe there are some companies who will look negatively on a 30-something new grad, but f--k them anyhow, you dont want to work for a place like that. for every place that would reject you based on being 10 years older than the average new grad, there are plenty of places who will hire you without even considering this non-issue, and give you the opp'ty to build your skills.

now, i realize the economy is still down, and hiring is suppressed generally speaking, but this is across the board in all industries.

i dont know where hte duckman works, but if he thinks that 30-35 year old entry level IT candidates are going to be broadly snubbed because they are in their 30's then he's got a tenuous grasp on the reality of industry hiring procedure.

look, just be aggressive in your job search and treat your job search …

jephthah 1,888 Posting Maven

Ctrl z is not a C function. IOW, the interpretation of ctrl-z is system dependent, and is not necessarily EOF. For example, on unix, ctrl-d is used as EOF. On systems where ctrl-z is used, it still doesn't always get interpreted as eof, as you have seen

for microsoft OS, ctrl-z is only EOF when it is found at the beginning of the input stream. in this case EOF is a negative value (-1). when ctrl-z is found in the middle of an input stream after text, it is interpreted as a non-printable ascii character, just like any other escaped character. in this case:

ctrl-a = 0x01
ctrl-b = 0x02
...
ctrl-z = 0x1A

you can test it yourself by trying different combinations of text and control characters. remember the printf() is blocking and will buffer the standard input until a newline is entered, so you'll have to hit <enter> after any given amount of text.

#include <stdio.h>

int main() {
    int c;

    while (1)
    {
        putchar(c = getchar());
        printf(" %c = %#X\n",c,c);
    }
    return 0;
}
popcorn99 commented: leet h4x0r +0
kvprajapati commented: helpful. +9
jephthah 1,888 Posting Maven

i figured it was a cut-and-paste typo .. they happen to everyone, don't sweat it too much. i almost didn't notice it, because its one of those that don't trigger a compiler warning. becoming able to see these improves w/ experience. just try to slow down.and not rush things when programming and debugging. sometimes you have to walk away and go do something different for a few hours and come back later. :)

also, i didn't note it, but changed your debug printfs... you were using %s when you needed to be using %c to print meaningful information.

good luck, and come back if you need more help :)

jephthah 1,888 Posting Maven

no it's not. it's terrible. it's ugly. and it's unportable. it wont even compile on a standard C compiler. i doubt it even works.

jephthah 1,888 Posting Maven

the logic of your palindrome function was correct, but there were a few errors in your code structure that prevented the function from being executed properly.

. i have commented out the errors and put notes indicating what the error was.

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

 #define MAX_LEN 50

/* Create external function */
char palindrome (char *string, int len)
{
    //len = strlen(string-1);   <--- NO, do not try to take length of pointer!!
    //                               this is why "len" is passed in as an argument!
   
    
    printf("\nEntering palindrome():\n   str \"%s\", len %d\n", string, len);
 
    if (len <= 1) 
    {
       printf("   remaining length %d, all done \n", len);
       return 1;
    }
    else if (string[0] != string[--len])
    {
       printf("   str[0] \'%c\' != str[%d] \'%c\'\n", string[0], len, string[len]);
       return 0;
    }
    else 
    {
       printf("   str[0] \'%c\' == str[%d] \'%c\'\n", string[0], len, string[len]);
       return palindrome(++string, --len);
    }
}


int main(void)
{
/* Create variable for string */
    char string[MAX_LEN];
    int len;

    // char palindrome (char *string, int len);  <--- NO, do not declare prototypes 
    //                                                inside the main() function !!!


    /* Explain purpose of program to user and prompts for input */
    printf("This program will test a phrase inputted by you to see\n");
    printf("if it is a palindrome.\n\n");
    printf("Please enter a word or phrase of no more than 50 characters.\n\n>");


    /* Receive input from user and stores it in input_string array */
    scanf("%s", string);

    len = strlen(string);   // <-- DO get the length of the string after the input

    /* Call external …
tux4life commented: ++rep for all your effort :) +8
jephthah 1,888 Posting Maven

look, i'm tellin' ya, dood, everything you're trying to do is in Beej.

if only you'd bother to read it, you'd see for yourself, there's an entire chapter on message queues.

.there's no point in me trying to explain this to you at this point, because i haven't found a single introductory text that explains it better than Beej. i would just essentially be repeating everything he says. since he's already said it, why should i copy him.

just read the chapter already.

jephthah 1,888 Posting Maven

i swear, this guy.

i should probably be more tolerant, but his umpteen threads repeating the same problem, with the same variation on URGENT PLS HELP NOW headlines, along with his imperiously demanding tone.

it's just making it really difficult to care.

.

Salem commented: Indeed +20
jephthah 1,888 Posting Maven

The error I get in the compiler is "warning: control reaches end of non-void function in function char palindrome(char *, int).

char palindrome (char string[], int i)
{
    int ans;
    int k = strlen(string);

    if (k <= 1)
        ans = 1;
    else if (string[i] != string [k-1])
        ans = 0;
    else 
        return palindrome(string, i+1);

}

well, that's simple. you don't have a return statement for the first two conditions, only for the third. you need to always return.

i reccommend that you should have one and only one return statement at the end of the function, that will always be reached regardless of the conditional branches. \set the various return values in the conditional branches, but don't return until the end.

also notice how i indented your code. you should always indent your code properly. otherwise you can't hardly read the code and will be prone to making these kinds of errors.


another problem i see, is what is "ans"? you're setting this variable in teh function, but it serves no purpose and is neither returned nor passed back to the caller.


.

jephthah 1,888 Posting Maven

well, this is some kind of voodoo guru stuff. pretty clever use of shifts and AND'ing to perform a modulus.

But i think i'm seeing the basics: this is the LCG as it is implemented by Apple's Carbon C-language API, according to the wiki link i posted above

given the LCG equation, X[n+1] = (a*X[n] + c) mod m ,

the Carbon LCG implements it with a = 16807, c = 0 (a special case), and m = 2^31 - 1. The choice of these numbers involve modular arithmetic discussions on Mersenne Primes and primitive roots modulo, and i have to admit at that point it gets beyond me pretty quickly.

but notice that in your program, as it stands, your 'tempseed' value = 33614 * 1, and then this is then shifted right 1 bit, which is the same as dividing by 2 ... so now you have 16807 (the 'q' variable in the program).

this next part is a little confusing:

to teh above 'q' value it adds the 'p' value, which is the upper 32 bits from the previous 64-bit seed. this initially is less than 32 bits, so that added value = 0, but as this iterative process develops, the seed varies across most of the range of a 64-bit value so the corresponding upper 32 bits (the 'p' variable) is a meaningful value.

now this part follows the explanation you received:

this summed value has its modulo …

jonsca commented: Nice attept to elucidate it -- I couldn't begin to tell you if it's correct +4
jephthah 1,888 Posting Maven

Now that's just wishful thinking ;)

hey, it's not about me.

we always dream of a better place for our children.


.

jephthah 1,888 Posting Maven

That being said, we are launching a new design for the site in about a month. I will give it a try at first, not using a modal, and see if all of the activity stats drop off.

and this is the new design where posts are automatically closed after 3 months of inactivity.

right?

:)

Nick Evan commented: Haha +0
jephthah 1,888 Posting Maven

one problem is your function, palindrome, expects two integers to be passed into it. you've declared these integers in main as 'i' and 'k' but you don't assign any value to them before passing them into the call to palindrome. therefore, they will either be zero or some large value of random garbage.

also, your function palindrome, which has two ints being passed as inputs, then completely ignores whatever input you might have passed in for the one called 'k' and assigns a value of string length to it.

you probably want to remove 'int k' from the palindrome function prototype, and declare 'int k' as local variable in palindrome.

this still doesn't fix the fact that you are not passing anything in for 'i' what is the purpose of 'i' what should the 'main()' routine be setting it to, before passing it into the palindrome function.

there are other problems. that's just a start. but it will probably lead you to discover and fix them.

you really should be running this in a debugger, to step through each line and check what the variables are being set to.

jephthah 1,888 Posting Maven

I need your help AT ONCE plz IN C CODE ONLY

... NOW write equation like this

yeah, i'm gonna suggest that you rethink how you phrase requests.

I dont know about your native language, but in English language when you are requesting for someone to help you, and you use the IMPERATIVE tone as an ORDER ... well, you're just going to get everyone pissed off at you and no one will help.

good night, and good luck.

Salem commented: "Romanes eunt domus" +20
jephthah 1,888 Posting Maven

okay, i'm a new user who just logged in to make my very first post ever, because i found some old thread on google, and i'm prepared to dazzle the world with my "solution" on how to best "gets()" input from the terminal.

i'm already ignoring the bold text on the message input that says the same thing. why would a popup be any different?

just lock the stale threads down. random posts 3 years after the fact don't contribute anything, they just make this site look like its full of retards to anyone who finds it afterwards.

jephthah 1,888 Posting Maven

something's not right, here. how are you gonna neuter a cat named "Betty" ?

:S

Aia commented: It became Betty after the operation. Haha! +8
jonsca commented: Dude, FTW +4
WaltP commented: The same you neuter my dog named Rex, since she squats to pee. :P +11