|
Ari posted:But why are you learning both C and C++ at once? Heh, because I can't stop myself from wanting to mess with one or the other. So far it hasn't really been a big deal, but if it gets to the point where I can't separate the two, I'll stick with one.
|
# ? Feb 25, 2008 19:30 |
|
|
# ? May 4, 2024 17:15 |
|
Ari posted:The question comes up pretty often as to the de facto library of books for learning various programming languages and concepts. In my experience reading threads discussing them and reading several of the books named, I think the general goon consensus is that Eckel's Thinking in C++ is the best one to pick up C++. But why are you learning both C and C++ at once? Also Koenig's Accelerated C++: http://www.amazon.com/Accelerated-Practical-Programming-Example-Depth/dp/020170353X
|
# ? Feb 26, 2008 17:33 |
|
fret logic posted:Heh, because I can't stop myself from wanting to mess with one or the other. So far it hasn't really been a big deal, but if it gets to the point where I can't separate the two, I'll stick with one.
|
# ? Feb 26, 2008 17:56 |
|
Professor Science posted:Stick with C at first, because you will get confused between pointers and references and arrays and STL containers and new and malloc and all the things they do differently. Once you can look at C++ and see how it's built on top of C clearly, it will make a lot more sense. Alright I'll do that. I'm probably going to pick up a paper copy of K&R today, was just surprised that it's still $50 at the bookstore. edit: Woohoo bought it. Oh, and I was thinking, if anyone else is learning C and wants a study buddy of sorts, I'd be down for it. I learn a lot better when I have someone to bounce concepts off of. fret logic fucked around with this message at 04:38 on Feb 27, 2008 |
# ? Feb 26, 2008 22:25 |
|
fret logic posted:Alright I'll do that. I'm probably going to pick up a paper copy of K&R today, was just surprised that it's still $50 at the bookstore. K&R is so completely worth it, though. You'll be very glad you bought it. Chapter 5 of that book is a beautiful piece of technical writing, and probably the best tutorial on pointers I've seen.
|
# ? Feb 27, 2008 05:44 |
|
Mikey-San posted:K&R is so completely worth it, though. You'll be very glad you bought it. Chapter 5 of that book is a beautiful piece of technical writing, and probably the best tutorial on pointers I've seen. I don't doubt it. From what I've heard about it, and from what I've got through so far, it's great. It helps that I really enjoy programming and technical books, but yeah I like it so far
|
# ? Feb 27, 2008 05:49 |
|
Really stupid question about Visual Studio 2008: I don't normally write Visual C stuff, but I found a command-line tool that I absolutely must have, and it was only available as source code. After a lot of rigamarole, I've managed to get a compiled .exe, but the file won't run on any other system! The error is always the same: The system cannot execute the specified program. I've tried installing the Visual C Runtime Libraries (for both 2005 & 2008) on my test machine, but it doesn't seem to make any difference. I know I'm probably being stupid, but I can't seem to figure out how to make this thing work. P.S. -- I only have the following includes, which I don't think are anything out of the ordinary: code:
|
# ? Feb 27, 2008 15:28 |
|
Mister Biff posted:Really stupid question about Visual Studio 2008: Download dependency walker (http://www.dependencywalker.com/) on your test machine and load the .exe and see whats missing. It's most likely something in the c runtime. Go into project settings, C/C++, code generation and switch it the runtime from Multi-Threaded DLL to Multi-Threaded.
|
# ? Feb 27, 2008 15:39 |
|
Mister Biff posted:Really stupid question about Visual Studio 2008: Since you say you've already installed the 2008 VC runtime libraries, check that you're compiling your app in release mode rather than debug mode. Doing a standalone install of the VCRT will probably only install the release versions, so check in event log to see why your app is failing to start - if it says it couldnt locate MSVCR90d.dll then you're running a debug build. The best way to ensure your app will work on other systems is to add a new Setup project to your solution, and tell it use the output of your main project. The setup project will detect and include all the required dll's, including the version of the CRT that you're linking against, and will install it correctly on the target machine.
|
# ? Feb 27, 2008 16:29 |
|
Thanks to both FigBug and beunges! Both tips turned out to be exactly what I needed. Thanks again.
|
# ? Feb 27, 2008 18:20 |
|
This is less a question and more a comment, but I discovered the following "feature" in typedefs today (don't ask how):code:
|
# ? Feb 28, 2008 06:01 |
|
Ok this is kind of a stupid question but I can't figure out why this works the way it does. I'm working with the getchar() and putchar() functions in C, and I don't understand how this loop is working:code:
Especially when... code:
|
# ? Feb 28, 2008 06:15 |
|
fret logic posted:Only returns the first character you enter. I thought that with the while loop, it does the first statement, you hit enter, then it does "putchar(c)", but I don't understand why it's holding the entire string of characters. Sorry if this is incredibly obvious Use Control-D to send an EOF character. (In Linux, at least) The reason it looks like it's holding the entire string in memory is because stdin is line-based -- nothing is sent to the program until you press Enter. You type in the line of text, and the program then processes that line, one character at a time. Scaevolus fucked around with this message at 06:24 on Feb 28, 2008 |
# ? Feb 28, 2008 06:20 |
|
Avenging Dentist posted:This is less a question and more a comment, but I discovered the following "feature" in typedefs today (don't ask how): Why the hell would it compile? x is a sub::bar, which is the same as a base::foo, so it doesn't have a b member. Only sub::foo, which is a completely unrelated struct, has a b member.
|
# ? Feb 28, 2008 06:26 |
|
Scaevolus posted:Use Control-D to send an EOF character. (In Linux, at least) How is this different from the one without the loop? It'll let you type in an entire string, but only returns the first character. Are you saying that once you hit enter, it repeats the loop for each character in the line? I guess I'm not understanding how the loop affects the process.
|
# ? Feb 28, 2008 06:27 |
|
JoeNotCharles posted:Why the hell would it compile? x is a sub::bar, which is the same as a base::foo, so it doesn't have a b member. Only sub::foo, which is a completely unrelated struct, has a b member. Well yes, that's the point. The example is greatly simplified; the original involved a complicated chain of template instantiations and was non-obvious, especially since it broke in a completely separate area (the typedef'd template was instantiated with base::foo and all subsequent references to that template, typedef'd or not, used that instantiation). Most of it is kinda obvious in retrospect, but template metaprogramming has a tendency to make obvious things not-so-obvious. EDIT: I am sure it doesn't help that I have been unable to concentrate on anything for the last couple months. Avenging Dentist fucked around with this message at 06:38 on Feb 28, 2008 |
# ? Feb 28, 2008 06:34 |
|
fret logic posted:How is this different from the one without the loop? It'll let you type in an entire string, but only returns the first character. Are you saying that once you hit enter, it repeats the loop for each character in the line? I guess I'm not understanding how the loop affects the process. Here's how it works: You: Start program Program: Initialize, getchar() [Now the program is waiting for input, and is idle] You: Input text, [enter] [Now a line of input has been entered, and the program's getchar() finally returns a value] Loop version: --Program: Print character, getchar() Without loop: --Program: Print character, exit
|
# ? Feb 28, 2008 06:37 |
|
Ok now I feel really stupid, but it's still not clicking for me. If I rearranged the program to:code:
edit: oops code is wrong in this one ^, fixed it, and tried on my laptop, it gives the same output as the first loop, so I'm still confused :/ fret logic fucked around with this message at 06:56 on Feb 28, 2008 |
# ? Feb 28, 2008 06:50 |
|
code:
1: c isn't initialized so you don't have any idea what's in c at the moment. 2: You're testing the value of c, but you don't know what c is. This is bad. 3: c becomes the return value of getchar(). getchar() will not return until the end of file or end of line is reached. So in your example let's say you type in a word like "stuff." 4: Whatever character c is, show it. 5: Go back to the top, and 2: since c isn't a "." (it's a "s") we continue to line 3 again. 3: c becomes the next character from stdin, you've already given the next character before, it's "t". getchar() won't wait for you to hit enter this time because it doesn't need to. ... Eventually c becomes "." and we end the loop, having printed out "stuff" to stdout. The reason stdin works like this is because it's line-buffered, that's just how it works. Here's an ok discussion with some more information. fret logic posted:I'm in WinXP right now so I can't try it out
|
# ? Feb 28, 2008 07:31 |
|
Avenging Dentist posted:Well yes, that's the point. The example is greatly simplified; the original involved a complicated chain of template instantiations and was non-obvious, especially since it broke in a completely separate area (the typedef'd template was instantiated with base::foo and all subsequent references to that template, typedef'd or not, used that instantiation). Oh, I thought the "argh" was "argh C++ is so stupid why won't it let me do this" and not "argh I am so stupid how did I gently caress this up".
|
# ? Feb 28, 2008 08:38 |
|
Lexical Unit posted:3: c becomes the return value of getchar(). getchar() will not return until the end of file or end of line is reached. So in your example let's say you type in a word like "stuff." Lexical Unit posted:3: c becomes the next character from stdin, you've already given the next character before, it's "t". getchar() won't wait for you to hit enter this time because it doesn't need to. Thanks man, the bolded parts did it for me this time. That's what I was having so much trouble understanding, was that it kept an entire line in the memory, and that in the first one without the loop, it only printed out the first letter because I only called the putchar() function once. I'm going to do some more research on stdin now Lexical Unit posted:Can't you use Visual Studio Express — it's free to download. Haha yeah I have it installed on here, but given that I haven't figured out how to use it, it annoys the ever living piss out of me. It's far too much labor for a simple C program like that, I am a freak for command line compiling now.
|
# ? Feb 28, 2008 08:53 |
|
Avenging Dentist posted:Well yes, that's the point. The example is greatly simplified; the original involved a complicated chain of template instantiations and was non-obvious, especially since it broke in a completely separate area (the typedef'd template was instantiated with base::foo and all subsequent references to that template, typedef'd or not, used that instantiation). Are you saying that the base class was dependent on a template argument of the child? If so, on a compliant compiler you should have gotten an error at the typedef which would have probably saved you some trouble (since foo there isn't a dependent name you'd get error in the first phase before you even instantiate the template, but vc++ won't catch this because it incorrectly pushes everything off to instantiation). It always helps to use gcc instead of vc++ when doing template stuff.
|
# ? Feb 28, 2008 16:20 |
|
That Turkey Story posted:Are you saying that the base class was dependent on a template argument of the child? Not exactly, though I should probably update Cygwin and run my stuff through gcc at some point. A more complete example of my problem would be: code:
|
# ? Feb 28, 2008 17:29 |
|
What are some good websites besides Euler with stepping programming tasks that you don't have to know an entire language to do? Like ones you can do while learning a language
|
# ? Feb 29, 2008 07:41 |
|
Not to appear that I've abandoned my own question, but I worked out the problem after the advice I got from this thread pointed me back in right direction. I was messing around with daemonizing the program at the same time. I'd created the Log object, then called my daemonize function. The child process "lost" the Log object. Moving the creation of the Log object after the daemonization (probably just moving it to after the forking of the process) solved the issue. JoeNotCharles posted:Is your log class flushing the stream? Doesn't using endl trigger a buffer flush on it's own?
|
# ? Feb 29, 2008 07:52 |
|
I'm interested in doing some windows API/mfc programming and a little bit of directX/openGL. VS Express is turning out to be a piss-poor tool for doing this (no api/mfc libraries, no resource editor). So aside from forking over $280 for a full version of VS, is there anyway I can actually get a tool that doesn't feel like it's fighting me at every step of the way? I think I'm going to try finding my old copy of visual C++ 6 hidden away somewhere. I vaguely remember it having a resource editor and windows libraries.
|
# ? Feb 29, 2008 11:34 |
|
You downloaded and installed the platform SDK, right? And followed Microsoft's instructions on how to set up VS Express to use it and have the ability to create Win32 apps, right? That should be all you need to utilize the Win32 API (Win32 API != MFC). You would still lack a resource editor, but IMHO it would be far better to use VS Express and suffer without a resource editor than to go back to VS 6.0.
|
# ? Feb 29, 2008 12:37 |
|
Yeah I've finally gotten the platform SDK set up. I figured out that I had downloaded the wrong SDK and got the proper link to the platform SDK. Everything is working better now except that I'm editing resource files by hand. At least I can compile the sample programs now.
|
# ? Feb 29, 2008 13:03 |
|
I'm currently getting started in C, by using it to write a compiler of sorts (its for an assignment). Much of the code is generated already by BNFC (from the grammar I've written) , but I need to edit it to traverse my tree and do stuff. My question is what is a good development environment to start off in C? I've been using eclipse for java, but the C version doesn't seem to be as usable. What would you all recommend? I'm using Mac OS X, if it matters.
|
# ? Mar 1, 2008 02:08 |
|
Red Oktober posted:I'm currently getting started in C, by using it to write a compiler of sorts (its for an assignment). Pretty much the only choice you have is Xcode, which is free once you sign up for a developer account on Apple's site (also free). You can also probably find it on your OS X install disc.
|
# ? Mar 1, 2008 02:40 |
|
Red Oktober posted:I'm currently getting started in C, by using it to write a compiler of sorts (its for an assignment). I'd suggest taking this opportunity to learn about working without an IDE, especially since you're getting started with C. IDEs tend to abstract away a lot of important details about the C/C++ compilation model, which may come back to bite you later. I would say to find a text editor that you like -- TextMate seems to be the favorite on OS X for just about everyone except the Vim users, or Vim if you want to be a real programmer^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H learn Vim. Then learn to use gcc and make, enough to write a simple Makefile.
|
# ? Mar 1, 2008 04:44 |
|
more falafel please posted:Then learn to use gcc and make, enough to write a simple Makefile. Simple makefile?! Maybe at first, but if you were really into it, you'd go all out and use autotools. Vim (especially with ctags/etc) and autotools make a fantastic development environment.
|
# ? Mar 1, 2008 04:48 |
|
Peanutmonger posted:Simple makefile?! Maybe at first, but if you were really into it, you'd go all out and use autotools. Vim (especially with ctags/etc) and autotools make a fantastic development environment. Do you have a good resource for more information on using autotools (esp. with vim)? I'd like to do something like that, but don't know where to start.
|
# ? Mar 1, 2008 05:33 |
|
Peanutmonger posted:Simple makefile?! Maybe at first, but if you were really into it, you'd go all out and use autotools. Vim (especially with ctags/etc) and autotools make a fantastic development environment. You're insane. Autotools are ridiculously terrible to work with.
|
# ? Mar 1, 2008 06:05 |
|
JoeNotCharles posted:You're insane. Autotools are ridiculously terrible to work with. I have to agree. The reason for Autotools in the first place was to deal with shortcomings of the various implementations of Make and different compilers. Since those are relatively rare today there isn't a lot of reason to start a new project with Autotools. Even just using Make can get tedious on large projects. Modern, usable build controls systems exist such as CMake. In fact KDE semi-recently switched over to CMake.
|
# ? Mar 1, 2008 06:12 |
|
ColdPie: I found the sources I used from googling "autotools", there are some books that are free now (but old) that give good tips. There are some tutorials that give good basic forms of the files, and for configure.ac 'autoscan' can give good suggestions for macros. However, you're probably better off with a small makefile JoeNotCharles posted:You're insane. Autotools are ridiculously terrible to work with. I probably am. I also probably haven't used autotools well enough to get out of the "honeymoon" phase of how wonderful it is that configure will discover everything for me and build a Makefile with all of the targets I've come to expect. I really enjoyed doing a "make dist" and copying that to my other desktop and building it. On the other hand, for things that won't leave your computer, I suppose a simple makefile should do very well. (I'm a little bitter about "simple makefile"s in packages I've downloaded that, from bit rot or whatever, ended with me rewriting the makefile so it would actually work) 6174: cmake looks very promising. It's a little annoying that they chose the name cmake (since we have make, gmake, bmake), especially when it doesn't replace make, but that's okay. It also makes sense that KDE would choose it, since it loses all of the dependencies that autotools had, and they're heading for super cross-platformness. I don't have it installed currently (other than KDE4, the list of packages using it seems small), but maybe I'll test it out on one of my toy projects. Generating a VS project would be very nice... Well, I originally felt silly for posting that comment, but it appears to have turned out reasonably educational.
|
# ? Mar 1, 2008 09:44 |
|
Peanutmonger posted:6174: If cmake isn't to your liking there are other options too such as SCons, and Boost.Jam. If you're using a language other than C or C++ the options also change, but I won't mention those since this is the C/C++ thread. Basically it is pretty easy to find alternatives because Autotools isn't a good solution today. The main problem it used to solve is different today, and it has some screwy features, like the use of M4. M4 is just a pain in the rear end and asking a developer to become even somewhat familiar with it to build a program is just wrong.
|
# ? Mar 1, 2008 16:12 |
|
I say make and not autotools (or a better build system like CMake, SCons, or Boost.Jam) because it's simple and you're more likely to run into that, at least in the C/C++ world, than something else. For a simple project with a few source files, a Makefile would look like this: code:
|
# ? Mar 1, 2008 18:58 |
|
more falafel please posted:For a simple project with a few source files, a Makefile would look like this: What about a project with 40 source files and multiple targets? At some point you just want to let the computer take care of it.
|
# ? Mar 1, 2008 19:29 |
|
|
# ? May 4, 2024 17:15 |
|
HB posted:What about a project with 40 source files and multiple targets? Not to mention traversing directories and making makefiles for each directory. Eclipse does a pretty good job of making makefiles, in my opinion.
|
# ? Mar 1, 2008 20:18 |