If we do the same thing for females, we get 35/74 =.472. To get the odds ratio, which is the ratio of the two odds that we have just calculated, we get.472/.246 = 1.918. As we can see in the output below, this is exactly the odds ratio we obtain from the logistic regression. May 18, 2010 Some of the smartest dummies Can't read the language of Egyptian mummies An' a fly go a moon And can't find food for the starving tummies. Against all odds, now? Chorus Sabali, sabali, sabali. To compute your $2 win price, take the odds of your horse and multiply the first number by 2, divide that by the second number, and then add $2 — simple as that!

The latest and most trendy function for reading a string of text is getline(). It’s a new C library function, having appeared around 2010 or so.
You might not have heard of the getline() function, and a few C programmers avoid it because it uses — brace yourself — pointers! Even so, it’s a good line-input function, and something you should be familiar with, even if you don’t plan on using it.

Odds For Dummies

Here’s a typical getline() statement:

The getline() function is prototyped in the stdio.h header file. Here are the three arguments:

&buffer is the address of the first character position where the input string will be stored. It’s not the base address of the buffer, but of the first character in the buffer. This pointer type (a pointer-pointer or the ** thing) causes massive confusion.

&size is the address of the variable that holds the size of the input buffer, another pointer.

stdin is the input file handle. So you could use getline() to read a line of text from a file, but when stdin is specified, standard input is read.

Here’s a sample program:

The string input is stored at the memory location referenced by pointer buffer, declared at Line 8.

Lines 9 and 10 use the size_t variable type, which is a special type of integer. That’s required by the getline() function. The buffer size is 32 characters, which is set at Line 9. It must be referenced as a pointer, not a literal value.

In this code, 32 bytes of storage are assigned to memory location buffer via the malloc() function at Line 12. Lines 13 through 17 handle the (rare) condition when memory isn’t available. Odds are low that would happen in this program, but it’s good programming practice to check.

The getline() function debuts at Line 20. It uses the address of buffer, bufsize, and then stdin for standard input.

Because variable characters is a size_t variable type, the %zu placeholder is used in the printf() function at Line 21.

Here’s a sample run:

Betting Odds For Dummies

Notice anything annoying with the output?

Poker Pot Odds For Dummies

Yep, as with the fgets() function, getline() reads and stores the newline character as part of the string. So if the pointer thing bothers you, just use fgets() instead.

Finally, if you’re curious, you can use getline() with array notation for the storage buffer. It ain’t pretty, but it works:

Betting Odds 4 5

To get the ** type of pointer from array notation, you need to declare a pointer variable and assign it to the array, which is done above in Line 8. You can then use that pointer with the ampersand in the getline() function, shown above at Line 13.