How much C?

I'm wanting to help a friend who doesn't know anything about C or C++ learn C++. I'm still learning both languages myself, but I'm enrolled in classes at a University. I know there's a bit of cross over between the two in the sense that one may likely use C functions in their C++ applications, but I was curious as to how much C (if any) one should learn before learning C++. For example, C strings are great tools for learning about pointers and how arrays behave in these languages, but, given what classes are available in C++, learning about C strings has limited value past that. So would having him learn about C strings (for example) be a waste of time if he plans on doing most everything the C++ way?
Last edited on
I would suggest teaching him C++ first, as it is much more advanced than C is.

Obviously, the first thing that he would do, is a simple cout << "Hello, World!" << endl; statement, which should be fine. However, through homework, he may find that the principle of a printf() function makes more sense than one that uses operator 's.

It will show devotion, though, if he chooses to strife through the tougher language, as opposed to the simpler one.


[simpler, as in syntactically. Keep your wig on.]
Last edited on
1
2
printf("Hello, World!");
cout << "Hello, World!";


Which would look easier to comprehend?
There are no prerequisites for learning C++.
I'd show him C++ first, C is a little simpler and IMO easier to learn once you already have some programming knowledge.
I believe one should first learn how to use the tools (following your example, learn how to use std::string to do string manipulations and I/O) then learn what they are made of (C-style arrays of char and the use of pointers as iterators). It's not a waste of time learning those, but it's a delay in reaching a grasp on the language learning those *first*.
I'd recomend starting with C++. It easier to get onto really useful things like objects and it has a much more versatile standard library.

Once you're up and doing things with C++ you can then start looking into how it works and venturing into the world of C.
Just going to echo the "Start with C++" from the posts above. My first introduction to C++ was a guide from Microsoft which began with a very theoretical explanation of C. I gave up after 40 pages, being non-the-wiser. C++ allows you to do some very advanced programming without actually knowing what happens behind the scenes. Pointers are terrible in the first few weeks, but you can fully avoid(or at least postpone) using them through the STL. Dynamic allocation? Mo' like vector.
Ha well then it looks like going straight for C++ is what we'll be doing.

Thanks for all of the responses and suggestions. I do like the idea of C++ first, it seems a bit less frustrating because of (for instance) the actual string type, vectors, and other little things that help tackle issues with memory without really tackling them yourself. I also like the suggestion of letting him get a feel for that stuff, then showing him what is really going on; I think he'll grow to appreciate C++ more that way.

Thanks again everyone.
Topic archived. No new replies allowed.