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
Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

csammis posted:

Has this man read TAOCP? :raise:
Hahaha, I know him and can guarantee that he has not.

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

tef posted:

Why don't you two take this outside and settle this like real programmers ?
Whoah, outside? What kind of language-warring programmer goes out there?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Vanadium posted:

No, mail software still breaks at ~80 characters and terminals and consoles and whatever are still 80 characters in width. :shobon:
1) Mail software shouldn't edit e-mails after I tell it to send. 2) Unless you're talking about actual, physical teletypwriters, the width can easily be changed.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Cody Watts posted:

Can anyone think of a way around it?
I'm pretty sure the Windows API has a call to set the current working directory. I don't remember what it's called, though.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

JoeNotCharles posted:

The standard way on Unix is to look at argv[0], which has the full path to the executable.
Not necessarily. I put an argv-printing program in a directory in my path and get whatever string that I call the program as:
code:
% gcc -std=c99 args.c 
% ./a.out 
./a.out
% ./a.out hi
./a.out
hi
% mv a.out bin/
% a.out
a.out
% bin/a.out
bin/a.out
% ./bin/a.out 
./bin/a.out
% ././././bin/a.out 
././././bin/a.out
%
I'm on Fedora 8 & bash.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Pensive Goat posted:

Since all methods in Java are virtual by default, all instances of a class will carry around a reference to each of their (non-final) methods. So if all of these methods can be stored in an external class, each instance of the original class only needs a reference to the external class instead of references to each method.
That wording makes it sound like an object has a reference per member method, but I'm sure that Java implements it as one reference to a table of all member methods.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Runaway Five posted:

How do I make my C++ Visual Studio 2005 projects build/compile/link in such a way that as an executable they can stand alone and run on another computer which does not have Visual Studio installed on it.
They need either the VC++ runtime library installed or you need to statically link to it at build time.

Deployment
More deployment

This gets asked a lot; could you add info on it to the first post, Avenging Dentist? Oops, this isn't the C++ thread

Mustach fucked around with this message at 00:04 on Aug 25, 2008

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Aw man, I'm under so much register pressure these days, I can hardly get it up.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
oops, ignore me

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Just use realloc()
code:
size_t len = strlen(p->messageid) + sprintf(buff, "%d", pagecount++);
char* messageid = realloc(p->messageid, len+1);
if(!messageid) oops();
p->messageid = strcat(messageid, buff);
edit: made it warning-free and less lines to boot

Mustach fucked around with this message at 04:24 on Sep 6, 2008

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Plastic Jesus posted:

You can't re-use a pointer passed to realloc (that's why it returns a pointer)
I assigned the result of realloc to another variable.

quote:

#define MAX_UINT32_AS_STR_LEN strlen("4294967295") + 1
...
char buff[MAX_UINT32_AS_STR_LEN];
This won't work in C89, and even in C99 and C++ it has the added problems of re-calculating the length of a non-portable string literal in every spot the macro is used. If you really just gotta be sure buff is big enough to hold the string representation of page count:
code:
char *buff = malloc(floor(log10(pagecount)) + 2);
but really you'd be pretty safe with something like
code:
char buff[124];

Mustach fucked around with this message at 15:27 on Sep 6, 2008

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

floWenoL posted:

If it's so safe, why'd you bump it up from 100? :P
Well, my failed joke is that any arbirary large size above 20* will be fine if you know the buffer is only going to hold the string representation of an integer. I admit it's still a gamble, but it's probably going to be a while before hardware supports more digits (and even then, plain old int might not change).

*For the number of digits in a 64-bit unsigned long, I think? I dunno that's why I'd just use something big.

edit: bleh, that was way too much explaination on my part

Mustach fucked around with this message at 14:43 on Sep 7, 2008

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

floWenoL posted:

Why in god's name are you not using a hashtable.
Specifically, C#'s Dictionary.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Vanadium posted:

Can you not just use LINQ or something in this case
What are you, Victor?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
pow() returns a double. Using %d to print a double will give you incorrect output. That is the only problem.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
It's the same problem: pow() returns a double, but none of those variables that you're assigning the results to are doubles.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Go to Project >> Whatever Your Project is Called Properties >> Configuration Properties >> C/C++ >> Preprocessor, make sure WIN32 is part of the Preprocessor Definitions.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Runaway Five posted:

I have a question and a half.

When you use the STL Standard Map, it is implemented as a "Binary Tree" and therefore runs in O(lg) time.

Is there a STL form of a hash table, one that would work in O(k) time and preferably have a subscript operator? Thanks in advance.
std::tr1::unordered_map, from the header <unordered_map>. If you're on Windows, you'll need to install the Standard C++ Library TR1 Extensions

quote:

Also, is there such a thing as a hash map?
Map, table, same difference.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
func() changes a specific x that any other function can use. func(x) changes a copy of whatever variable you pass to it. "Method" is a synonymn for "function."

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Man, you shoulda told him to implement his own HTTP library. Fast as gently caress

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

MSDN on Math.Round(Double) posted:

If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that the method returns a Double type rather than an integral type.

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.
Interesting.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
code:
bash-3.2$ for d in whatever/*; do echo $d; done
whatever/hello there.txt
whatever/number two.txt
bash-3.2$ ARRAY=("My Documents" "Favorites"\
 "Application Data" "Local Settings" "Desktop" "Templates")
bash-3.2$ for f in "${ARRAY[@]}"; do echo $f; done
My Documents
Favorites
Application Data
Local Settings
Desktop
Templates

BDA7DD posted:

Please help me fix my lovely syntax, I'm bound to understand it once I actually learn it.
Nah, bash is the one with the incredibly lovely syntax. It really is the worst.

edit: Beaten, because I spent like twenty minutes double-checking everything with the manual, because bash syntax is a horrible, un-remember-able beast. Did I mention that I hate bash?

Mustach fucked around with this message at 16:47 on Feb 14, 2009

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
You don't need cygwin to run those programs on Windows.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
People here like to recommend the O'Reilly "Programming C#" book, but I'm not a fan of the author's writing style, especially if you're looking for something approaching Kernighan's style.

Are you looking for a book that covers only the core language, or some .NET and Windows, Winforms, WPF, etc. as well?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
How high are your high-performance requirements?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Haskell is the best language for solving trivial problems.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Not as cool as the Curly Howard isomorphism.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Does your class have an assigned book? Chances are that it's a much better learning source than anything you'll find on the Internet.

Trifling Fox posted:

Since you gave out that particular link, I'll rescind my call for help and look elsewhere.
One person gives you a snarky answer and you completely give up?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
TortoiseSVN

edit: oh, I see, under XP and linux

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Uhhhh, didn't you just post that in it's own thread yesterday and get an answer?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Probably because he's gay.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
edit: ugh I'm an illiterate idiot

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
What did you take those screencaps with?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

DoctorTristan posted:

Not sure if this is the right place to ask, but does anyone know where the phrase `Embarrassingly parallel' was first coined, or by whom? I'm using it in a maths paper and should probably cite it somehow.
I hope you never get published. Or get an F, whatever

Mustach fucked around with this message at 01:17 on Sep 20, 2009

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Don't care; it's the dumbest "term" ever and people should stop using it

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
"Embarrassing"'s dumb because you just used a far more accurate, appropriate, and descriptive replacement ("trivial").

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Does Victor even exist anymore?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

RussianManiac posted:

anything that inherits from Collection such as maps
They don't.

quote:

I think for-each is best when you just want to modify each element but not when you want to delete it.
You can't.

quote:

In that case you will run into concurrent modification exceptions.
It won't.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

RussianManiac posted:

Collection has method to return iterator, although specifically it appears that class has to implement http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html to be allowed in for-each loop.
I misunderstood you on the deletion part, but Map is not a Collection or an Iterable.

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
The docs say that it's backed by the Map, so probably.

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