|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
arrays and string common libaries (newbie question)
when studying my first C++ book i wonder why the hell c++ has limitations to arrays. why it can't be like in any other language that u just make an array grow by pushing values into it...
same for strings, other languages provide very efficient arithmetics to handle them... so i wondered if someone already made a very common libary that overrides the standard c++ functionality in order to provide these - "essentials". otherwise i really first would need to do them on my own... i am using Bloodshed Dev-C++ but shouldn't make a real diffrence... sorry if this has been asked a thousand times already, i was not able to find it ![]() |
|
#2
|
||||
|
||||
|
Hi,
Try looking up references to the vector class, which is the kind of dynamically sized array I think you're looking for. Try here: http://www.cprogramming.com/tutorial/stl/vector.html Also, there is a string class in C++, that isn't in C, which is *much* better than using an array of chars. There's a good guide which has exercises too here: http://www.cse.fau.edu/~cot3002l/stringsC++/ Confused me for a while too, especially the vector notation, but stick with it, cos it's very useful! Hope this helps :-)
__________________
Practise Random Kindness |
|
#3
|
|||
|
|||
|
THNX!
well the first link is somewhat - err - "wired" because this is somekind of half half thingy but anyway i gonna have a closer look, the second link seems really helpfull thanx. but hm, this vector thing seems to b a common standard right so possibly my compiler knows it already? i was looking for an array object that is like hmm - able to b multidimensional. and having the standard push shift pop unshift reverse concat... and the like functionality (like java, php, actionscript...) ... is there perhaps another tutorial on this vector stuff where the rest of these r going to b mentioned or does the vector class just have these few commands mentioned on that site? |
|
#4
|
||||
|
||||
|
Re: arrays and string common libaries (newbie question)
Quote:
So that we can write overflow exploits of course ![]()
__________________
Two things have come out of Berkeley, Unix and LSD. It is uncertain which caused the other. |
|
#5
|
||||
|
||||
|
Sorry,
Forgot to mention that you want to #include <vector> as well. There are lots of methods that can be used in the vector class. Does Dev-C++ do drop-down lists of member attributes and methods? If it does, you could declare a vector object and then use that to see what's possible. Most of the names are pretty obvious, and you can at least search for the names of those that aren't as straightforward. As, for a 2D array, you might be able to declare it of type: vector<vector <int>> which would be a 2D dynamically sized array of ints. Can anybody confirm this by the way, as I've only used them a couple of times... Might be a total load of rubbish :-) Any time you see a class type with <> next to it, it's a 'template' which take a type as a parameter. Googling "c++ templates" should throw up lots of useful sites. I posted a question here on this topic myself recently - "Using static modifier with templates", and it contains a small class that uses templates (though part of the syntax was initially wrong, hence the post! :-) ). Most c++ books will tell you more about them I should think, but as always it's just a case of knowing what terms to look out for... Good luck! |
|
#6
|
|||||
|
|||||
|
Quote:
so that u don't need to care anymore. @ majelbstoat or #include <vector.h> sure //err, btw. what the hell is the diffrence? something related to c's history right? Quote:
no < ![]() damn, i knew it, i need a reference! Quote:
yes, that obviously is a beginners problem ![]() allright, so i think i first gonna get myself another book also describing that template stuff... Thanx alot majelbstoat |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > arrays and string common libaries (newbie question) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|