Unofficial Programming Thread

Post » Thu Sep 23, 2010 4:10 pm

I don't really know why it would only return drive H:, assuming the others are all bigger than one gigabyte. Sure they are, right..

You can do wmi queries by running wmic.exe on the command line. If you type:
logicaldisk where (size >= 1073741824) list brief

It should return the same list that you are getting. I don't know is there some kind of buffer on the WriteLine, but it should print the text out immediately, right?
User avatar
Wayne W
 
Posts: 3482
Joined: Sun Jun 17, 2007 5:49 am

Post » Thu Sep 23, 2010 2:09 pm

I think I might have it setup wrong in the Main method. Since there would only be one object it takes the last value I put into the property. Since H: is the last drive thats what gets output. So I am tryign to figure out how to make a new object for each drive. I think if I created the array in Main and looped it that might work. I would just need to create a second array for the disks.

As it is it works perfect. But if I add properties to it then it only gives me the last one.
User avatar
Your Mum
 
Posts: 3434
Joined: Sun Jun 25, 2006 6:23 pm

Post » Thu Sep 23, 2010 6:46 am

Well, if I copy paste that code and run it, it print out everything just fine:

Drive Total Size Free Space
C:\ 99,9gb 71,09gb
D:\ 365,76gb 286,24gb

It even finds the network shares that were mapped to letters. It prints everything to console when you call GetDisks(). It might be better to implement separate functions for GetDisks and PrintDisks. Store the string array of disk letters to a member variable, or property as they are technically called, I think. Then a separate function to feed those letters to the loop. It should work ok.
User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Thu Sep 23, 2010 4:26 pm

Well, if I copy paste that code and run it, it print out everything just fine:

Drive Total Size Free Space
C:\ 99,9gb 71,09gb
D:\ 365,76gb 286,24gb

It even finds the network shares that were mapped to letters. It prints everything to console when you call GetDisks(). It might be better to implement separate functions for GetDisks and PrintDisks. Store the string array of disk letters to a member variable, or property as they are technically called, I think. Then a separate function to feed those letters to the loop. It should work ok.

Yeah that is what I am tryign todo, make properties for each variable.
User avatar
Natalie J Webster
 
Posts: 3488
Joined: Tue Jul 25, 2006 1:35 pm

Post » Thu Sep 23, 2010 7:13 am

I've been studying some C lately and it's a lot of fun, it's a lot different from Python (the only other programming language I'm familiar with except for PHP) but I'm getting the hang of it. ^_^
User avatar
kristy dunn
 
Posts: 3410
Joined: Thu Mar 01, 2007 2:08 am

Post » Thu Sep 23, 2010 6:04 pm

I've been studying some C lately and it's a lot of fun, it's a lot different from Python (the only other programming language I'm familiar with except for PHP) but I'm getting the hang of it. ^_^


If you're doing C you may as well do C++ considering it's essentially the same thing with extra features (namely object orientation).
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am

Post » Thu Sep 23, 2010 1:09 pm

.
User avatar
Mr.Broom30
 
Posts: 3433
Joined: Thu Nov 08, 2007 2:05 pm

Post » Thu Sep 23, 2010 2:50 pm

If you're doing C you may as well do C++ considering it's essentially the same thing with extra features (namely object orientation).


C++ may be a superset of C, but it's profitable to treat them as different, mutually intelligible languages. There are use cases suitable for one or the other, and good C++ code != good C code.
User avatar
Svenja Hedrich
 
Posts: 3496
Joined: Mon Apr 23, 2007 3:18 pm

Post » Thu Sep 23, 2010 3:51 am

C++ may be a superset of C, but it's profitable to treat them as different, mutually intelligible languages. There are use cases suitable for one or the other, and good C++ code != good C code.

QFT. This was what I had written above and then deleted. Case in point would be http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization. One of the things that you should always try to use in C++ but C doesn't even have. (It is very hard/impossible to write exception safe code without RAII).
User avatar
Markie Mark
 
Posts: 3420
Joined: Tue Dec 04, 2007 7:24 am

Post » Thu Sep 23, 2010 2:35 am

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.
User avatar
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Thu Sep 23, 2010 8:28 am

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.

C is much neater than C++, and I personally like it from a purism point of view, but in practice you'll be rewriting half of the C++ library if you want to use C in any real program other than pure low-level number crunching.
User avatar
Louise Andrew
 
Posts: 3333
Joined: Mon Nov 27, 2006 8:01 am

Post » Thu Sep 23, 2010 10:33 am

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.


Personally, I like writing object oriented code, so I prefer C++ any day of the week.
User avatar
Unstoppable Judge
 
Posts: 3337
Joined: Sat Jul 29, 2006 11:22 pm

Post » Thu Sep 23, 2010 6:12 am

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.


C's good for applications where the interaction with the rest of the world is text and binary I/O.

If you want to interact with your program by windows and dialogs and widgets, C++ wins.
User avatar
JLG
 
Posts: 3364
Joined: Fri Oct 19, 2007 7:42 pm

Post » Thu Sep 23, 2010 5:51 pm

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.

The standard library and templates makes C++ worth it. The downside is C++ is far more complex.

C++ has a larger userbase and from what I have seen more open source projects use it. There are also more C++ libraries (By virtue of the fact that you can also use C libraries) available. You would for example be hard pressed to find a really active rendering library in C, where as there are a multitude of ones written for C++.

C will possibly teach you more about how the machine works faster as C++ hides some of what it does. I also agree with Max when he says C is much neater than C++. C++s greatest asset and worst design feature was that it was backwards compatible with C.
User avatar
Sheeva
 
Posts: 3353
Joined: Sat Nov 11, 2006 2:46 am

Post » Thu Sep 23, 2010 9:32 am

So I have been reconsidering how I want to setup my toolkit. I am now thinking something command line but would still be created in C# and require .NET 3.0 or 3.5. Would this be a wise move as opposed to using WPF? It would mainly be for personal use anyways so I don't need anything too fancy.
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Thu Sep 23, 2010 3:40 am

QUESTION!

Should I have chosen C++ instead of C? I'm going to be creating small, non-commercial application for personal use, I figured C was the better choice here since it's been around a lot longer and frankly C++ looks really unnecessary complex. Also I hear that C is better for small applications.

Pure C makes you think more in line of procedures and can be very linear. Object oriented C++ encourages you to create the data model first by design. You can have the procedures attached to the data (objects) and that way describe what you want to do with the data. In my opinion it's much easier to design bigger applications through data, than structuring detached procedures here and there. For me, ANSI C, is a pure pain in the butt and I haven't done that since early 90's.. Then again, a "class" is nothing more than a glorified C struct with inheritance. There are differences but the languages are not too different. Too much a like, in my opinion, in fact.

C# takes that a bit further btw, by renaming things, improving IDE, and libraries, simplifying and shortening some stuff (get/set, COM), configuration etc and making you write the implementation within the class definition more or less.

Cobol and Fortran have been around a lot longer than any of these, but not many people really like or know how to code in that..

If your applications are small, it's really one and the same, either C or C++ will do, but good design always makes modifications easier. You are still going to want to improve some things and develop new stuff over time.
User avatar
Lewis Morel
 
Posts: 3431
Joined: Thu Aug 16, 2007 7:40 pm

Post » Thu Sep 23, 2010 2:18 pm

So I just came across the site http://www.codechef.com/, it has lots of sample problems for practice and shows solutions from people who did them successfully. I thought I might share it here for others to see, it might benefit someone.
User avatar
Fanny Rouyé
 
Posts: 3316
Joined: Sun Mar 25, 2007 9:47 am

Post » Thu Sep 23, 2010 1:50 pm

So I just came across the site http://www.codechef.com/, it has lots of sample problems for practice and shows solutions from people who did them successfully. I thought I might share it here for others to see, it might benefit someone.

Cool. I might give some of them a go. It looks like a slightly less maths oriented version of Project Euler.
User avatar
Rachel Eloise Getoutofmyface
 
Posts: 3445
Joined: Mon Oct 09, 2006 5:20 pm

Post » Thu Sep 23, 2010 4:20 pm

It looks like you only need to sign up if you want to submit your solutions. Not many people seem to be posting code done in C# on there which is what I use. It is kind of understandable though as the machine that runs the tests might not be compatible with the .NET framework.
User avatar
Ana Torrecilla Cabeza
 
Posts: 3427
Joined: Wed Jun 28, 2006 6:15 pm

Post » Thu Sep 23, 2010 10:51 am

It looks like you only need to sign up if you want to submit your solutions. Not many people seem to be posting code done in C# on there which is what I use. It is kind of understandable though as the machine that runs the tests might not be compatible with the .NET framework.


Their test machine runs Gentoo Linux. It does support C#, presumably with Mono standing in for .NET. That gives you compatibility up to .NET 2.0 but no support for COM.
User avatar
Emilie M
 
Posts: 3419
Joined: Fri Mar 16, 2007 9:08 am

Post » Thu Sep 23, 2010 11:28 am

So I have this program I started awhile back and released for Medieval 2 Total War but users keep getting an error I can't duplicate and I don't see where it even comes from. My program is around 400 lines of code, most of which is commented but not all of it.

The program just added entries to the registry to allow mods to be run from the M2TW launcher if the user has the Steam version since normal mod shortcuts don't work properly.

Would someone be able to look over my code, I have either a Visual Studio 2008 or 2010 solution file. It also relies on an XML file which I have with the code. I really haven't had time to really look into it and am not sure when I will get some time, but its also difficult to even duplicate the error. I could throw an exception in my code but there is no telling if its in the same place as it occurs for the users. and all they get is that it is an object reference error.
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Thu Sep 23, 2010 7:13 am

So I just came across the site http://www.codechef.com/, it has lots of sample problems for practice and shows solutions from people who did them successfully. I thought I might share it here for others to see, it might benefit someone.

Thanks, looks fun. Solved one medium level problem and posted it, but my prime number solution was apparently taking too long to finish and I have to study properties of prime numbers to optimize it or something. However, on my machine it finished in fractions of a second for a maximum set described in the problem (one million prime numbers). I am now measuring performance in clock ticks, but I think most of the time is spent in I/O when writing out the result set.
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Thu Sep 23, 2010 12:11 pm

Thanks, looks fun. Solved one medium level problem and posted it, but my prime number solution was apparently taking too long to finish and I have to study properties of prime numbers to optimize it or something.

I don't know how you are finding primes, but the methods I know about are the http://en.wikipedia.org/wiki/Sieve_of_Atkin or the slightly easier (to implement) http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Thu Sep 23, 2010 3:26 pm

I don't know how you are finding primes, but the methods I know about are the http://en.wikipedia.org/wiki/Sieve_of_Atkin or the slightly easier (to implement) http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Well, never actually having done this before, I tried brute force which apparently didn't meat the requirements too well. I'm trying the latter sieve that you mentioned now, but skip processing all number divisible by 2 with it and somehow optimize the process of finding primes only within a range. That would be within my grasp at the moment. I don't know a thing about the more sophisticated and efficient methods.. This sieve method could potentially consume a lot of memory so I'm trying to do it with a bitset.
User avatar
Channing
 
Posts: 3393
Joined: Thu Nov 30, 2006 4:05 pm

Post » Thu Sep 23, 2010 2:21 pm

Just seriously looked into http://code.google.com/p/angel-engine/, recommended by a SJML. It's clicking, and seems to be exactly what I'm looking for.

What do you guys think about a 2d platformer, based around a caveman with a ropegun? That's my concept so far, while I'm in bed I'll begin on the story and possibly level design. Let's see where my mind takes me.


This isn't programming related, but why haven't any games used the Stone Age as a setting? There's so much to work with, not to mention how hilarious it could potentially be.

The closest I've ever saw was Fallout 2 with the primitives, aside from that there's no other RPG that covers the time period - that I've played.
User avatar
lucile
 
Posts: 3371
Joined: Thu Mar 22, 2007 4:37 pm

PreviousNext

Return to Othor Games