r/programminghomework • • Oct 07 '12

Need Help C++

Please help me. My professor just gave us homework. Thanks to my crappy luck Im left alone to do it. Anyway. My problem is to make a program that lets the user input words(as many as the user wanted) and List characters that are in the words then count how many. from A to Z .. Uppercase and lowercase .. Please help .. I thank you in advance . Im so lost cause she has only taught us the basics up to using arrays .. We are using Visual studio 2007 ..

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/nokia1280 Oct 08 '12

I must add, Why must I generally avoid arrays in C++?

2

u/sablefoxx Oct 08 '12

They tend to lead to programming errors if you're not extremely careful. They have their place of course, but for the most part you should default to using Vectors as they manage themselves (you can keep adding data to a Vector, and it will automatically re-size itself). Especially if you're dealing with code that uses the network, as using static sized arrays often lead to buffer overflows (https://en.wikipedia.org/wiki/Buffer_overflows) which can allow hackers (such as myself, hehe) to remotely inject arbitrary code into your program over the network and take control of your computer/server.

In C++ it's also a good idea to use the string class (std::string) as apposed to an array of chars (for similar reasons).

1

u/nokia1280 Oct 09 '12

I should give you an idea of what my professor taught us, Basics Cin,cout, If statements, loops and nested loops, lastly arrays. so its a bummer we have to make our own program that has to impress a programmer. Its like torture mate. Thanks for the help.