Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
POKEMAN SAM
Jul 8, 2004

Vanadium posted:

I am pretty sure that fflushing input streams does not do anything.

From the man page:

code:
Flushing  an  input  stream  discards any buffered input and
adjusts the file pointer such that the next input  operation
accesses  the  byte  after  the  last one read.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

HB posted:

The OS X 10.5 manpage for fflush makes no mention of input streams; it only says the function will fail if the stream is "not open for writing".

I found it on this site http://www.hmug.org/man/3/fflush.php but I guess that's only for ISO C90?

POKEMAN SAM
Jul 8, 2004
Edit: Nevermind, checkexits or whatever prints. I was confused by the name of the function.

POKEMAN SAM
Jul 8, 2004
Whenever you're using a Room in a parameter or return value, do Room * so it affects the real one, not the copy.

POKEMAN SAM
Jul 8, 2004

more falafel please posted:

Looks like at least some browsers (Safari at least) treat & p i ) ; as & p i ;, which should render as the pi symbol.

I see the PI symbol, and I'm on Firefox 2. Looks like & p i itself makes the PI symbol (it ignores the character following it, i.e. doesn't wait for a semi-colon.)


&pi

POKEMAN SAM
Jul 8, 2004

Vanadium posted:

It is not browser specific, the forums do the substitution. You can tell by looking at the source. :ssh:

What? The source shows me the & p i, not the symbol.

POKEMAN SAM
Jul 8, 2004

more falafel please posted:

You have absolutely no understanding of what you're talking about.

Doesn't adding another bit simply double the range (assuming you're only using non-negative numbers anyways.)

e.g. a signed byte is 0-127 (again, assuming you aren't using the negatives), but an unsigned byte can be 0-255. If you're adding another bit doesn't that, by definition, double your range?

POKEMAN SAM
Jul 8, 2004

sarehu posted:

Here's an algorithm that scales better with respect to integer size. I don't think it's a good idea to use a macro.

Why not? It can be verified that it works properly just like the function you posted can.

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

Macros are evil, and unless you absolutely have to, it's preferable to use an inline function to enforce type safety and all that good stuff.

The 'macros are evil' is pretty lame, but I understand the type safety argument.

POKEMAN SAM
Jul 8, 2004

Lexical Unit posted:

At that point someone from our company has travel to another company to do integration testing. Which just means we compile and run our code in the other company's environment and get both of our systems up and running and see that they actually work together as the spec says they should. Obviously there's usually problems at this point as it's the first time either company has interacted with each others' components.

How is this a problem from using "non-default" libraries? Instead of including a Header and CPP files in your project you include a Header and LIB files...

POKEMAN SAM
Jul 8, 2004

Hammerite posted:

Why does it say that there's no such function when there clearly is, and I've even defined the function further up in the same file?

I can't see any obvious problems, but would you mind sticking the .CPP and .H files on Pastebin or something so we can see it all in context?

POKEMAN SAM
Jul 8, 2004

That Turkey Story posted:

destroybtn != destroybutton

ensurebtn != ensurebutton

Bah, how'd I miss that :(

POKEMAN SAM
Jul 8, 2004

TSDK posted:

Ignoring possible overloads, then it should compile to identical code.

I've worked with people who prefer the '== false' on negative conditions, but omit the '== true' for positive conditions, on the grounds that it's harder to misread compared to the possibility of not spotting a small '!' tacked on to the front.

I'm in this boat. Unless it's obvious that you're going to be checking that something is false, I use == false.

POKEMAN SAM
Jul 8, 2004

Mustach posted:

(Although a lot of the time they'll say "Visual C++" and mean C++/CLI.)

Where do they do this?

POKEMAN SAM
Jul 8, 2004

ShoulderDaemon posted:

Using a tool to build your state table seems like cheating.

This is why I love the CoC.

POKEMAN SAM
Jul 8, 2004

king_kilr posted:

I think questions like that tend to be a bit too easy, for example I'm a freshman CS student and I immediately see the problem there :/

You'd be surprised who shows up at interviews saying they can program.

POKEMAN SAM
Jul 8, 2004

hexadecimal posted:

How can something like that be possible?

A lot of the time you don't need a Bachelor's in CS to pursue a Master's in CS, for example a lot of schools will let you hop right into a Master's in CS program with a Physics or Math degree. Though you might need to take classes to satisfy prerequisites for the classes in the graduate school, you'll probably avoid taking any introductory programming classes, and often the Graduate CS classes are weighted more toward theory than programming, so you might not do much (if any) programming in Graduate school.

POKEMAN SAM
Jul 8, 2004

rawstorm posted:

Okay, forget about the previous code I posted, let's say I dynamically allocate memory to an array of vector <int>'s like so:
code:
int fooNum = 5;
vector<int> *foo = new int[fooNum];
Now I want to free up the memory I just allocated. What do I need to type on the next line that would free up that memory?

That won't work, either. You can't take a pointer to vector<int> and assign it a pointer to space for fooNum ints.

Specifically, if you try to, you'd get this:

code:
error: cannot convert 'int*' to 'std::vector<int, std::allocator<int> >*' in initialization

POKEMAN SAM
Jul 8, 2004

rawstorm posted:

Okay thanks guys. :)

I have a feeling he's still just doing

code:
delete a;
a = NULL;
Which is still wrong in his case...

POKEMAN SAM
Jul 8, 2004

hexadecimal posted:

It would be fine if it was constructive criticism, but I swear to god that half of my posts here just had responses trying to make fun of it for no good reason other than trolling.

And granted, I am still learning so I did make mistakes in my posts, and I feel like I learned from informative responses some people have made.

If you'd just stop smoking pot all of the time I think you'd see all of the problems in your posts. Not to mention that half of the time you don't even properly capitalize, which shows how little you really care about your own posts.

POKEMAN SAM
Jul 8, 2004

Nippashish posted:

Keep the terminal open? "Up+Enter" is pretty quick.

Also, pro-tip: g++ untitled.cpp && ./a.out This will compile untitled.cpp, and will only run a.out if it compiles successfully.

POKEMAN SAM
Jul 8, 2004

Dijkstracula posted:

code:
int[] ret;

for i=0..9 do
  ret[i] = i;
end


for i=0..9 do
  int j = rand() mod n;
  int k = rand() mod n;

  pair temp = ret[j];
  ret[j] = ret[k];
  ret[k] = temp;
end
edit: added array generation just to make it clear, and changed a variable name that I used twice.

Ugh, this still isn't a properly shuffled array.

POKEMAN SAM
Jul 8, 2004

Jo posted:

It's late and I'm getting retarded. Is there an obvious flaw with this function?


Are you sure those values are going to fit into an int?

POKEMAN SAM
Jul 8, 2004

Anunnaki posted:

Okay, this is driving me up a wall. Can somebody tell me why this is giving a seg fault? It happens on line 18.

http://pastebin.com/d66a3c60f

Let's see how box is defined and passed into the function.

POKEMAN SAM
Jul 8, 2004

Bitruder posted:

I used TinyXML in a recent project and it's very simple to use. One thing to note, however, is that in the latest version on their website, it will not parse spaces in attributes of tags (it returns everything UP TO the first space).

What do you mean spaces in attributes of tags? This isn't valid XML: <House The Name="White House" />. Unless you mean spaces in the attribute values, then that's a pretty big bug that would be missed by the TinyXML team.

POKEMAN SAM
Jul 8, 2004

ShoulderDaemon posted:

Shell scripts are written in shell, which has almost nothing whatsoever to do with C or C++. You should probably post your question in the Linux thread.

What if you use the C shell (csh)?

POKEMAN SAM
Jul 8, 2004

Mustach posted:

Which is worse, an Avenging Dentist or a Grumpy Doctor?

Which is worse at programming? :D

POKEMAN SAM
Jul 8, 2004

Contero posted:

Luabind looks fantastic. Thank you so much.


I'll check this out also.

Just roll your own Scheme interpreter; the language is trivial.

:colbert:

POKEMAN SAM
Jul 8, 2004

That Turkey Story posted:

You can with the power of SFINAE (or in C++0x with concepts)! With boost this can be done with Boost.TypeTraits and enable_if:

code:
template< typename T, typename Enabler = void >
class CarDealership;

template< typename T >
class CarDealership< T, typename enable_if< is_convertible< T*, Car* > >::type >
{
  // Definition here
};

haha, "is_convertible" for cars

POKEMAN SAM
Jul 8, 2004

csammis posted:

If you're set up to pull Windows symbols from the Microsoft symbol servers automatically instead of on-demand, that process can take a really long time.

This means you've debugged WPF applications before!

</offtopic>

POKEMAN SAM
Jul 8, 2004
If you can choose where (IP:Port) the program connects, you can write a simple pass-through proxy and drop the packets in there. Would take but 10 minutes work.

POKEMAN SAM
Jul 8, 2004

Red Blaze posted:

This works great. I will just use this macro so I know the context of the error.

#define glColor4f(r,g,b,a) glColor4fDontUse(r*g*b*a)

Can't you just undefine it?

POKEMAN SAM
Jul 8, 2004

That Turkey Story posted:

No.

Oh, I was thinking the original one was a macro defined outside of his project so he was stuck with it. My bad.

POKEMAN SAM
Jul 8, 2004

Chuu posted:

I have a function:

code:
void doSomething(int x){..}
Currently this code is being called, x is always a literal from an enum.

Is there any way, at compile time, to enforce then x can only be certain values, without breaking interface? Macros are fine.

If I am willing to break the interface, can templates and/or Macros solve this problem easily?

You can use Boost Static Asserts or roll your own Static Asserts (it's not hard using template trickery.)

Here's the Boost ones, I'm sure you can find an implementation of your own if you look around.

http://www.boost.org/doc/libs/1_31_0/libs/static_assert/static_assert.htm

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

EDIT: Oh also static asserts won't work because the value of x is known only at runtime.

Oh I figured since it was a compile time check he wanted he was hardcoding calls to the function and wanted to make sure he was only using the subset of the allowed ones, or something. Obviously I wouldn't have suggested static asserts if I knew the values were run-time.

POKEMAN SAM
Jul 8, 2004

Jethro posted:

Re-inventing the wheel is often a good idea when you're learning about wagonmaking in general.

There's more to a wagon than its wheels, though, so it's still a valid exercise to make a wagon given wheels.

POKEMAN SAM
Jul 8, 2004
I'm playing around with TMP in GCC 4.3.2's half-implementation of C++0x, and I was wondering if there was a way to somehow do the following:

code:

template <char x, char... c>
struct mystruct {
...
};

int main () {

   mystruct<"asdf">::go();

}

It obviously won't let me do it just like that, and I thought I'd get lucky by using user-defined literals to transform the "asdf" string during compile-time, but GCC 4.3 doesn't support user-defined literals...

POKEMAN SAM
Jul 8, 2004

That Turkey Story posted:

Yeah, I'm kind of in the same boat of no money, but I'm going anyway, after which I will be basically broke.

Have you started looking for a new job?

POKEMAN SAM
Jul 8, 2004

That Turkey Story posted:

Wait, do I know you? I've been putting it off, but I started updating my resume this morning and have a couple of places in mind. Registering for Boostcon immediately after getting laid off probably wasn't the smartest of ideas.

We talked a couple of days ago, you mentioned that you lost your job and seemed pretty bummed about it. Nothing a week of video games won't fix though, right? :)

Edit: Or you could spend your time in COBOL and make some origami versions of peoples' avatars!

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Zaxxon posted:

does anyone know a good way of changing HSB color to RGB without using floating point math?

Have you tried doing the math with 0-255 values as opposed to 0-1 values? Failing that, you could always use a Rational type to do all the math then at the end convert that to an int in 0-255 (or whatever your scale is) without using any floating point math.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply