|
To give you a basic idea on where i'm at, I'm just now getting into programming with no real experience. I'm starting off with C and Python, probably C for the most part though. I picked up the C Programming Language 2nd Edition today thinking it was a good beginner tutorial but apparently it assumes you have basic programming knowledge. Is there a good primer on the internet to get myself up to speed to the point where I can use this book? Also, what do I need on my PC (Windows Vista) to start programming? I've searched around for compilers but I don't really know what to look for.
|
# ? Dec 20, 2008 19:44 |
|
|
# ? May 12, 2024 21:19 |
|
IntoTheNihil posted:To give you a basic idea on where i'm at, I'm just now getting into programming with no real experience. I'm starting off with C and Python, probably C for the most part though. Dev C++ is probably the easiest and smallest IDE/Compiler package you can get, and is relatively user friendly when trying to compile small C/C++ programs. It is somewhat buggy though, just make sure you save a lot.
|
# ? Dec 20, 2008 20:59 |
|
Dev-C++ is possibly the worst IDE I've ever used. Microsoft Visual C++ is free, and the IDE is amazing.
|
# ? Dec 20, 2008 22:02 |
|
Seconding Dev-C++ being a terrible IDE. CodeBlocks is nice and light and much less terrible than Dev-C++.
|
# ? Dec 20, 2008 22:10 |
|
Nippashish posted:Seconding Dev-C++ being a terrible IDE. CodeBlocks is nice and light and much less terrible than Dev-C++. CodeBlocks also has the advantage of being cross platform if that's important to you. DevC++ is a pile of poo poo, and I can't believe I had to use that for my C++ class.
|
# ? Dec 20, 2008 22:13 |
|
The MVC++ install was insane. I think it took 2 hours total haha. It's seems great though even if I have no idea what i'm doing. edit: How do you get the compiled .exe files to stay on the screen for more than 1/8th of a second or can you. Kilometers Davis fucked around with this message at 00:45 on Dec 21, 2008 |
# ? Dec 21, 2008 00:22 |
|
IntoTheNihil posted:The MVC++ install was insane. I think it took 2 hours total haha. It's seems great though even if I have no idea what i'm doing. Run it from the command line, or do something like this when you want to wait for input: code:
|
# ? Dec 21, 2008 01:12 |
|
IntoTheNihil posted:The MVC++ install was insane. I think it took 2 hours total haha. It's seems great though even if I have no idea what i'm doing. Put system("PAUSE"); or char c; cin >> c; at the end of main(). Or run the programs from cmd.exe.
|
# ? Dec 21, 2008 01:13 |
|
IntoTheNihil posted:The MVC++ install was insane. I think it took 2 hours total haha. It's seems great though even if I have no idea what i'm doing. In Visual Studio, ctrl-f9 compiles, runs, and waits for user input at the end before terminating, whereas f9 disappears. It's in the Run menu.
|
# ? Dec 21, 2008 01:23 |
|
Is there a more clever way for cross-platform conditionals than usingcode:
|
# ? Dec 22, 2008 03:01 |
|
Create one thing.h that you include where you need it, and in that, have conditionals that include the platform specific header files.
|
# ? Dec 22, 2008 22:16 |
|
Bitruder posted:Create one thing.h that you include where you need it, and in that, have conditionals that include the platform specific header files. Thanks I actually wound up doing just that, actually. It's not perfect, but definitely better than the alternatives!
|
# ? Dec 23, 2008 08:18 |
|
I decided to give a go at the UVa problem sets. I'm doing Problem Set 100 right now, and I've hit a brick wall. I can get it working if I just do one string at a time, but it's a requirement to be able to put in multiple strings at a time. I've noticed that a lot of their problems do this, but I have had trouble with defining multiple variables with a single line before. Some googling came up with using stringstream, and it seems to work with just one line of input. However, after trying to get this working with several lines at a time, I think stringstream may be what's causing my current build to crash after the second line of input. I don't know if it's just not meant to reassign things or what. Can someone take a look at my code and tell me if they spot something that's causing the crash? (I don't want anyone to write the code for me, since that would just defeat the purpose, but a hint would be extremely helpful.) code:
Cosmopolitan fucked around with this message at 12:49 on Dec 23, 2008 |
# ? Dec 23, 2008 12:45 |
|
This is not how arrays work, you are making those into single-element arrays and then you are accessing nonexistant elements. You want to use std::vectors and push_back into them or something.
|
# ? Dec 23, 2008 13:16 |
|
Vanadium posted:This is not how arrays work, you are making those into single-element arrays and then you are accessing nonexistant elements. Oh, I thought not specifying a size, coupled with initializing it with a 0, would automatically fill the rest of any elements with a default of another 0. Now that I think about that, that doesn't make sense lol. Arrays are not dynamic. I'll look into vectors.
|
# ? Dec 23, 2008 21:21 |
|
dont' do system("cls") for uva problems. Also you want to be careful about your main loop and how you consume input. I had a lot of problem on this problem because of my first submission did not consume input correctly, and i think outputed an extra answer line. But here is a way that got AC. code:
hexadecimal fucked around with this message at 00:20 on Dec 24, 2008 |
# ? Dec 24, 2008 00:12 |
|
hexadecimal posted:also most of the time you want to abstain from C++ vector and just use static arrays. Make them as big as the boundary cases, and you'll be good. Hm yase, let's make memory use shoot through the roof because we hate the STL.
|
# ? Dec 24, 2008 00:21 |
|
hexadecimal posted:also most of the time you want to abstain from C++ vector and just use static arrays. Make them as big as the boundary cases, and you'll be good. Are you giving bad advice on purpose, or are you just a horrible programmer? I'm inclined to believe the latter because that is some truly horrible code.
|
# ? Dec 24, 2008 00:21 |
|
floWenoL posted:Are you giving bad advice on purpose, or are you just a horrible programmer? I'm inclined to believe the latter because that is some truly horrible code. It's a good advise for UVa problems because you are not trying to use good design here, just what works the fastest to solve particular problem. You allocate arrays with maximum size for some task because it will work for all test cases and you only make it once. You are shooting for speed and easy to program over memory usage. Using vector is slightly more expensive, and usually you can do all of the same things just with large arrays that you can reuse between problems (don't have to resize vector, or create new one). memset works faster than vectorz. Also what is so horrible about it. It was quick to write and passes the test cases. hexadecimal fucked around with this message at 00:26 on Dec 24, 2008 |
# ? Dec 24, 2008 00:23 |
|
Real men use a sparse array for something like this.
|
# ? Dec 24, 2008 00:33 |
|
Avenging Dentist posted:Real men use a sparse array for something like this. you mean storing previous 3n+1 solutions for some number?
|
# ? Dec 24, 2008 00:34 |
|
hexadecimal posted:It's a good advise for UVa problems because you are not trying to use good design here, just what works the fastest to solve particular problem. You allocate arrays with maximum size for some task because it will work for all test cases and you only make it once. You are shooting for speed and easy to program over memory usage. Speed is a bullshit reason, especially if you are talking about vectors vs. static arrays. vectors are definitely easier to work with than static arrays for all but the most trivial tasks. At worst, you can just call .reserve() or .resize() if you want. quote:Using vector is slightly more expensive, and usually you can do all of the same things just with large arrays that you can reuse between problems (don't have to resize vector, or create new one). memset works faster than vectorz. Speed is not a factor if you use vector right. I don't know what vectorz is, but I assume it's some vector-zeroing function you wrote. In any case, you can call memset on &v[0]. quote:Also what is so horrible about it. It was quick to write and passes the test cases. It's horrible enough that you had to clean it up a bit.
|
# ? Dec 24, 2008 00:44 |
|
Jesus Christ, why is this thread the most emotionally charged in all of cobol. Yea sure, vectors are fine, but a more important point was to just allocate them once as global variables then re-use them in your program between test cases. I had to clean it up because I copied it from a file where I had other implementations.
|
# ? Dec 24, 2008 00:51 |
|
hexadecimal posted:Jesus Christ, why is this thread the most emotionally charged in all of cobol. Yep, criticizing bad code/posts so that other people don't make the same mistake/follow bad advice is definitely "emotionally charged".
|
# ? Dec 24, 2008 00:58 |
|
Avenging Dentist posted:Yep, criticizing bad code/posts so that other people don't make the same mistake/follow bad advice is definitely "emotionally charged". It wasn't bad code and there are no mistakes as well as bad advise. You and floWenoL just nit picked one of my points in order to troll.
|
# ? Dec 24, 2008 01:00 |
|
hexadecimal posted:It wasn't bad code and there are no mistakes as well as bad advise. You and floWenoL just nit picked one of my points in order to troll. It was bad, or at least poorly-worded, advice. Believe it or not, I'm more interested in talking about C++ programming, which includes pointing out bad code/practices/advice, than in trolling anyone. Perhaps rather than crying 'troll', you should reflect on why it seems like every one of your programming-related posts has someone criticizing it.
|
# ? Dec 24, 2008 01:12 |
|
floWenoL posted:It was bad, or at least poorly-worded, advice. Believe it or not, I'm more interested in talking about C++ programming, which includes pointing out bad code/practices/advice, than in trolling anyone. Perhaps rather than crying 'troll', you should reflect on why it seems like every one of your programming-related posts has someone criticizing it. 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.
|
# ? Dec 24, 2008 01:22 |
|
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. 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.
|
# ? Dec 24, 2008 02:20 |
|
You can make trolling constructive criticism by figuring out why you're being trolled and stopping it. Trust me, I have experience! (being trolled)
|
# ? Dec 24, 2008 02:33 |
|
Alright, looks like I got it completely functional using vectors. I just wanted to ask a couple questions before submitting.hexadecimal posted:dont' do system("cls") for uva problems. How come? And what is the alternative? Also, are there any unanimous rules for UVa submissions that aren't listed in each problem description? (Such as the "No system("cls")" thing.) Edit: Also, I think the sample output on that page is wrong. Are they wrong, or am I wrong? Cosmopolitan fucked around with this message at 06:48 on Dec 24, 2008 |
# ? Dec 24, 2008 06:45 |
|
Presumably the entries are evaluated on a Unix box, where cls is meaningless. Basically, you really shouldn't need anything system-specific for these problems; just print the correct results to the console and don't worry about anything that your system/shell might have put there before your program started running.
|
# ? Dec 24, 2008 07:13 |
|
Anunnaki posted:How come? And what is the alternative? Anunnaki posted:Also, are there any unanimous rules for UVa submissions that aren't listed in each problem description? (Such as the "No system("cls")" thing.) Anunnaki posted:Edit: Also, I think the sample output on that page is wrong. Are they wrong, or am I wrong?
|
# ? Dec 24, 2008 07:14 |
|
ShoulderDaemon posted:You are wrong. The sample output is consistent with the problem description. Oh poo poo, okay, reading over the problem carefully, I realized I misunderstood the problem. Okay, I got it working correctly. My only problem now is that it seems if I enter a number with more than 4 digits, the program hangs at the input for the following line. Anyone know what's up with this? Since I don't want to create a wall of text, but it seems necessary to share the source code in its entirety to figure out the problem, here is a download link. Edit: Is this why they put a time limit on it? Edit 2: Never mind, I figured it out. Cosmopolitan fucked around with this message at 10:26 on Dec 27, 2008 |
# ? Dec 24, 2008 10:00 |
|
Okay so i am going to be working on a system developed with ArcObjects(uses COM) and the other half is straight C++. Should i use char* or std::string? I don't want to use CComBSTR since they only work on windows.. and half of the system is going to be run on Linux. So a general development point i was thinking of using STL for the middle ground. Good or bad idea?
|
# ? Dec 26, 2008 02:10 |
|
I'm taking a second semester intro to programming course this spring where we're transitioning from learning basic programming concepts in Python to C++. In Python it was a snap to run a file in TextMate, see the output/errors via PyMate, and close the window to get back to editing. My question is simple: how can I get that same one-button compile and run for single .cpp files? It seems silly opening a new Xcode project for every little thing I want to mess around with, but opening a terminal to g++ untitled.cpp, ./a.out after every save is cumbersome. EDIT: Updating the C .tmbundle with svn fixed it such that cmd+R runs stand alone. Problem solved! Equilibrium fucked around with this message at 21:00 on Dec 27, 2008 |
# ? Dec 26, 2008 07:14 |
|
Equilibrium posted:I'm taking a second semester intro to programming course this spring where we're transitioning from learning basic programming concepts in Python to C++. In Python it was a snap to run a file in TextMate, see the output/errors via PyMate, and close the window to get back to editing. My question is simple: how can I get that same one-button compile and run for single .cpp files? It seems silly opening a new Xcode project for every little thing I want to mess around with, but opening a terminal to g++ untitled.cpp, ./a.out after every save is cumbersome. Keep the terminal open? "Up+Enter" is pretty quick.
|
# ? Dec 26, 2008 08:25 |
|
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.
|
# ? Dec 26, 2008 10:05 |
|
This is probably something extremely simple but my brain is fried and I cant figure it out.... foo.h code:
code:
no 'void foo::doSomethingWithFoo()' member function defined in class 'foo' error... What the heck am I doing wrong? The rest of the code compiles just fine edit: Compiling and linking the class separetely seems to have fixed this...Still if someone can explain why it happens in the first place... shodanjr_gr fucked around with this message at 16:01 on Dec 26, 2008 |
# ? Dec 26, 2008 15:36 |
|
shodanjr_gr posted:Trying to compile this with g++ Works fine for me. Are you sure you omitted only irrelevant details?
|
# ? Dec 26, 2008 17:02 |
|
|
# ? May 12, 2024 21:19 |
|
Vanadium posted:Works fine for me. The only other thing in the class, is a second method, with a totally different prototype that works and compiles fine...
|
# ? Dec 26, 2008 18:32 |