| |
| |
| |
|
Page: 1 2 3 4 5 6
Comments:
<0> for 2 reasons.. <1> well, that IS valid, but it won't do at all what you think it will <2> 1 being to pointer <2> I had to order Accelerated C++ <1> ok <1> good <2> takes a while <0> no, it is not valid <0> can't add 2 pointers <2> Thats what I meant <0> and the other reason being that c is not initialized yet, making it undefined behavior <0> but the first is enough <2> yes <1> hmm <1> yeah I guess you can't <1> for some reason I expected you could
<2> That is even in my 10 y/o book <3> Can't do what? <1> add two pointers <3> Can only subtract <3> And if they're within a same block of allocated memory + 1 <3> Not that I've seen any OS enforce that one <3> (or machine) <1> ahh <3> Like char * p = new char[10]; <3> p < p + 9; // fine <3> p < p + 10; // fine (+1) <1> yeah <3> p < p + 11; // booh <3> Now for such a dumb line the compiler probably removes it :) <2> MrAshe... char tmp2 = static_cast<char>2; <2> isnt a right syntax right? <0> no <0> and no need for a cast <2> because its supposes to be <3> char>(2) <3> Imagine it's a function :p <2> strcat(data,&tmp2);strcat(data,suggestion[ii][i].c_str()); <2> will compile <1> sigh <3> And crash <2> but doesnt seem quite right <3> data += tmp2; <3> data += suggestion[ii][i]; <3> Gotta love strings <2> how about <1> no <1> not 'how about...' <1> just use what he just said <2> data += static_cast<char>(2); <3> Same thing <2> Okay <1> data += '\x2' <1> ; <2> mrAshe's brilliant <2> does that work to rdragon? <2> seems even better <3> '\x2' is an int :p <3> Ah wait, C++, then it's a char :p <1> heh <2> Where did you learn all that? <1> it's just an escape sequence to use the hex value as a character <1> you learn from books <0> you have to be a Phd in computer science to know that, which we all are <2> And how long did you studie books? <1> *shrug* I've been programming in general for most of my life <2> So you all phd's <2> can ya eat it 8:) <3> Pff, now I have to check the logs to paste the fun <0> Giovanni_, i was kidding.. phd is what usually comes after a masters in a university.. <4> how can I know the maximum index of vector<double> a1 . When Ill enter values and using a1.push_back function then how can I return the maximum index of the a1 vector ? <3> Anyway there's some guy asking how to put (without loss) 32-bit into 8-bit and telling me I just can't think beyond math (which is probably wrong) and it's possible <3> Heheh <0> ConiX, maximum index? you mean how many elements it has minus 1? <3> Who needs indices when you have iterators <1> std::numeric_limits< std::vector<double>::size_type >::max()
<4> well not really <4> the maximum number of elements <1> ConiX it's probably around 4 billion <4> no no you don't understand me <4> I mean <3> max_capacity() <4> the number of elements ill enter in the vector <1> the number of elements IN the vector? <1> v.size(); <1> I don't know how to calculate how many you 'will enter' <5> max_size <5> () <4> yes v.size() but then for example if the vector is a1 I can't write a1(v.size()) ! <1> uh <1> then you write a1.size() <3> Omg rdragon is so good at C++ <0> wtf <6> what's the h***le? <1> what do you need the size for? <5> lol <0> ConiX, do you want the last element? <7> good lord you, but mostly cowmoo, all **** <4> and then is there a function in what I can see all the elements in the vector ? <0> i.e a1.back() <1> what do you mean 'see' ? <3> template <typename T> typename T::size_type size( T const & v ) { return v.size(); } <6> ConiX what do you mean SEE ? <3> size(a1);!!!! <1> lol <5> wait what does he want to do? <5> I haven't figured out that part yet <7> he hasn't either <6> dunno, just got here <4> well to read all the elements <1> ConiX just iterate over them <4> cout << all the elements << endl; <5> unless he's trying to figure out that Khan is gaey, which is a no-brainer <1> hyrdogen, oxygen nitrogen... <3> copy( v.begin(), v.end(), ostream_iterator<whatever>(cout," ") ); <4> all the elements is the vector and a function what display all the elements <1> where 'whatever' is the element type of your vector <4> I need some loop to display all the elements in the vector collection or....... <6> ConiX pay ****ing attention <6> and you don't need a "loop" <6> see what MrAshe posted above <3> If typedefs worked on variables I could type copy( v.begin(), v.end(), ostream_iterator<v::value_type>(cout," ") ); <3> :'( <6> MrAshe yes, I've been bitching about that for almost a decade <6> so, ConiX what do you thing you need to do? <7> time out, awesome powahru <5> what <6> what do you think you need to do? <7> cowmoo = not bright <3> So dim <3> So VB <7> indeed <4> anyone of you have read the book "accelerated C++ practical programming by example" ? <4> im looking for the exercise files i can't find them nowhere <6> yes, I recommend it as a 1st book for everyone <1> yes, most here recommend it <6> "exercise files" ?? <4> well i am on the 3rd chapter and im stuck with the exercises <4> exercises on the end of the chapter <6> which exercise? <4> 3-3. Write a program to count how many times each distinct word appears in its input. <4> I have only basic knowledge of vectors and streams and they expect to do this with this knowledge ? <5> has it covered std::map yet <6> since that's the best solution <4> no it hasn't <4> std::map isnt still covered <4> just std::cout, std::endl, std::cin, std::string, std::streamsize, std::sort <4> and std::precision <4> that's all namespaces covered until now that I know <4> I was trying to sort the strings and then get the smallest one's
Return to
#c++ or Go to some related
logs:
#squid www.liveweb #squid #AllNiteCafe Dipsomaniac crave curent Date +java #c++ #javascript #java [usermod]
|
|