Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

what the FUCK?

Name: Anonymous 2006-09-27 16:48

I've been programming in C++ for a long, long time and I have never come across this particular problem before.

Here's the problem area in the code:

  float t = 0;

  for (t = 0.0f; t < 1.0f; t += 0.1f);
  {
    Q3.slerp(Q1, Q2, t);

    cout << t << "] " << Q3.w << "(" << Q3.x << ", "
         << Q3.y << ", " << Q3.z << ") " << endl;
  }

I just wanted to write a simple test program that outputs a series of values of a Quaternion that's SLERPed between two quaternions.

The problem is ONLY TIME ANYTHING IS OUTPUT TO STDOUT is at the VERY LAST ITERATION!!

I tried it with printf, too, and still the same thing.  I tried flush(stdout) as well as cout << flush in different parts of the loop, no such luck.

And I know that it is indeed looping because, say, if I change the third clause in the for loop to something like t += 0.000000001 it sits for a while, so I know it is actually going through the loop.

Why is cout and printf not printing jack shit until the loop is finished?

Also, optimizations are turned off.  I'm using gcc 4.0.0.  On another note, it won't let me declare:

for (float t = 0.0; t < 1.0f; t += 0.1f)

because it says I can't declare variables in the for loop, I had to do "float t" beforehand.  BULL SHIT.  Every other C++ compiler in existence lets me do this, and I know for a fact that doing so is allowed in the ISO standard.

But nevermind that, my real problem is why it isn't printing output within the loop until only the very last iteration.  What the hell is going on?

Name: Anonymous 2006-09-27 16:51

Oh god

....

...

Gee I wonder if it has anything to do with that semicolon at the end of the first line in my for loop.  Why the fuck did I put that there?  Why did I not even notice it until I posted this and made an ass out of myself?

Removing it fixes the problem.  And I'm able to use for (float t = blahblahblah)...
oh god why does this happen

Name: Anonymous 2006-09-27 17:48

It happened because you put your opening brace on a separate line, and instinctively you put a semicolon before the Enter.

This thread is now about ALLMAN STYLE SUCKS.

Name: Anonymous 2006-09-27 18:40

Accept thread change

Let's take a look at the four major styles:

GNU style:
if ()
  {
Shit sux fag. Who's the moron who came up with this shit? It's fugly, serves no practical purpose, wastes a line of text per loop making less code fit in your screen thus harder to read / more scrolling, and is harder to type. They managed to combine all the disadvantages of any style.

Whitesmiths style:
if ()
        {
Kinda ugly, and you waste one line. Plus 8 spaces per tab is ridiculous, 4 should have been the standard since the beginning of time.

Allman style:
if ()
{
Even worse than Whitesmiths because it looks uglier, and it's even easier to make the semicolon mistake than the previous two were, since the next line starts in the same column.

K&R style:
if () {Two gods, one true style. Finally, something that looks good, uses fewer lines, can't be mistaken for a non-block, and is easiest to type. The original tabs were 8 spaces, again, this is bad, but K&R style with 4 space tabs (or what's better, real tabs configured to show 4 spaces) is the best.

Name: Anonymous 2006-09-27 18:41

The code tag fails hard, even though I had newlines before and after all my opening and closing tags.

Name: Anonymous 2006-09-27 19:28

I prefer Allman style simply because my curly braces are aligned to the same column, so it makes it easier for me to see which ones match up to the other.

Name: Anonymous 2006-09-27 20:40

syntax doesn't do shit. Only amateurs whine about it.

Name: Anonymous 2006-09-27 21:08

DO YOUR OWN HOMEWORK FAGGOT

Name: Anonymous 2006-09-27 21:57

it's because you have a semicolon at the end of your for loop.  the part in the braces is only run once.

Name: moot !Ep8pui8Vw2 2006-09-28 1:09

>>9
THIS is why I hate C.

Name: Anonymous 2006-09-28 7:20

>>6
If you indent K&R properly, the closing brace will match with the opening block, and more importantly, the code inside a block is indented so no problem with it.

>>7
gb2/perl.org

>>10
You hate THAT? Then you're still a noob?

Name: moot !Ep8pui8Vw2 2006-09-28 12:22

>>11
Sorry, but that is a good reason to hate C syntax.  { B&; };

Name: Anonymous 2006-09-28 20:00

>>12
No, it is a horrible reason, I've never made that mistake and anyone who does is an idiot.

Name: Anonymous 2006-09-29 1:09

>>13

Is a liar.

Or too stupid to ever catch his own mistakes, oblivious moron.

Name: Anonymous 2006-09-29 3:34

>>14
Is an idiot.  Seriously, people who don't understand basic syntax for loops shouldn't be programming.

Name: Anonymous 2006-09-29 7:19

I'm sorry, but I think that >>13 is right, thought maybe a little harsh.  I've had syntax problems with C/C++, but I've never done that to a for loop, while loop, if/else statement, etc.

And it has nothing to do with code-style like >>3 implies.

Name: Anonymous 2006-09-29 8:35

Everybody who doesn't use Allman style needs to GB2 his 24 line terminal and off my Internet.

Name: Anonymous 2006-09-29 11:14

A.) People who use Allman style do so because it makes their curly braces line up, making the start and end of blocks easier to see.

B.) In K&R style, the closing curly brace still lines up with something -- the actual opening construct. Which means you can just as easily find the start of the block, AND you don't have to visually move up another line to find out what the hell that block IS. The inside of the block is still indented. It also saves you a keystroke and a line on screen.

People who use Allman style are using a style with absolutely no advantages over K&R.

Name: Anonymous 2006-09-29 12:36

>>17
This post is offtopic, remember the thread is about ALLMAN STYLE SUCKS.

Name: Anonymous 2006-09-29 15:38

>>1
use doubles instead of floats.

Name: Anonymous 2006-09-29 15:50

>>15

Dumbshit thinks the semicolon was on purpose, lol

Name: Anonymous 2006-09-29 18:32

>>1
God you're such a fucking failure. I immediately saw the extra semicolon after the for statement.

STOP FAILING SO HARD, GO BACK TO USING A FUCKING SCRIPT LANGUAGE LIKE PYTHON OR RUBY BECAUSE C IS OBVIOUSLY TOO *MANLY* FOR YOU.

Name: Anonymous 2006-09-29 22:45

>>20
There is no reason to use doubles unless you are writing some microscale simulation to be run on a supercomputer.  Few things need that much precision, and they are slow for real time applications.

Name: Anonymous 2006-09-30 5:04

>>23
You are one dumb motherfucker.

Name: Anonymous 2006-09-30 8:55

>>23
tard.

Doubles are the same size as a 32 bit machine word; there's no speed advantage to using floats unless you're using an ancient 16 bit computer.

Name: Anonymous 2006-09-30 11:24

>>25
IEEE standard Doubles are 64 bit, and IEEE standard floats are 32 bit.

Name: Anonymous 2006-09-30 15:28

>>26
whatEVERRRR

Name: Anonymous 2006-09-30 19:12

>>23 is actually tight, and >>25 is stupid

Name: Anonymous 2006-09-30 20:16

>>25
Like >>26 said, so you are retarded.  Also, try using doubles with graphics hardware and see what happens.

Name: Anonymous 2006-09-30 21:57

>>1
Looks like you have a semi-colon after the for statement, ergo, the code in the brances only runs once.

Name: Anonymous 2006-09-30 23:19

>>30
Looks like you don't read threads before replying, dipshit.

Name: Anonymous 2006-10-01 6:22

Some more websites:  TO SHOW SHADOW GOVERNMENTS EFFECTS AND FUTURE PLANS.

spp.gov

keeptexasmoving.com

nascocorridor.com   under trans texas, etc....

Name: Anonymous 2009-01-14 14:34

Satori

Name: Anonymous 2009-06-13 19:11

How do you guys format long conditional statements?

The only problem I have with k&r style is the way long conditionals are indented

if ((x > 10 && x < 37)
      || (x > 67 && x < 106)) {
   dothis();
}

if ((x > 10 && x < 37)
      ||(x > 67 && x < 106))
{
   dothis();
}

I find the second one easier to read

Name: Anonymous 2009-06-14 4:01

I use these cool macros when i code in c


#include <stdio.h>

#define IF if(
#define THEN ) {
#define ELSE } {
#define END  }

int main(int argc, char **argv) {
  IF !argv[1]
  THEN
    return 1;
  ELSE
    printf("%s\n",argv[1]);
  END
  return 0;
}

Name: Anonymous 2009-06-14 4:13

>>35
Oh god... It's horrible, burn it, burn it with fire!

>>34
I use K&R style, this is how I do long conditionals:


if ((x > 10 && x < 37) ||
    (x > 67 && x < 106)) {
   dothis();
}

Name: Anonymous 2009-06-14 8:41

>>36
multi-line if predicate. Oh god I think I'm dying help me oh god oooooooooohhhhhhh fuck

Name: Anonymous 2009-06-14 8:45

>>35
I think your ELSE is broken.

Name: Anonymous 2009-06-14 9:02

>>38
oh ya. good job i dont really use them

Name: Anonymous 2009-06-14 9:17

>>36
Braces go on their own line. Always.

Name: Anonymous 2009-06-14 9:21

>>40
Enjoy your wasting of 3 bytes every brace. ALLMAN STYLE IS BLOAT.

Name: Anonymous 2009-06-14 11:51

>>40
kill yourself

Name: Anonymous 2009-06-14 20:12

>>40
I must agree with >>42, please do off yourself promptly.

Name: Sgt.Kabu撓吣kiman䤢޺ 2012-05-28 20:15

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List