@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22



Comments:

<0> Heheh
<1> dun dun dun
<2> hey guys
<2> im running into a problem in vc++
<2> my understanding is when ever u use the "new" to ***ing mem to a pointer
<2> u have to use delete at the end
<2> correct?
<3> Correct.
<3> Any memory you ***ign with operator new, you must free with operator delete.
<1> scalar new (new) and vector new (new[]) require a corresponding call to scalar delete (delete) and vector delete (delete[]) when you want to release the memory that was previously allocated
<2> so let me ask a question what is the diff between delete [] pointer; and delete pointer;?
<3> Read what peterhu jsut said.
<3> They correspond to new [] and new, respectively.
<3> new isn't just a call to malloc. It also CONSTRUCTS objects.
<0> [20:57.03] <3> Any memory you ***ign with operator new
<0> Lie :>



<4> i have a prob with this http://www.noidea128.org/sourcefiles/15874.html the compiler error is at the bottom
<3> In an array, it'll construct multiple objects. So ti nees to destruct multiple objects, too. Hence the difference between scalar and vector enw and delete.
<3> -_-
<1> as such, it also destructs objects, which means that you need to use the correct delete. i think using scalar delete on a vector new allocated piece of memory is standardized as UB
<2> mark105: time to upgrade my friend
<4> KBM?
<2> in the NEW times "iostream.h" does not exist
<1> it's not part of standard c++
<3> mark: YouR'e returning a stack bsed array.
<1> in addition, your C++ professor is teaching you a bastardized C/C++ mix, as there is this thing called std::string in C++
<4> with my old school compiler we using for uni it does
<3> IE, you're returning a pointer to an object that'll cease existing as soon as you exit the function.
<0> new (lala) hihi;
<4> oh ok
<0> No need to call delete
<0> Har har har
<1> that's placement new, true
<1> no one uses placement new, you fool!
<1> though you do need to delete the memory that was previously allocated without placement new
<1> so YOU LOSE
<0> char blah[sizeof(hihi)]; new(blah) hihi;
<0> HAR HAR HAR
<1> ***uming the memory was allocated on the heap
<4> DrkMatter: whats the proper way to do it?
<1> and if i ever saw code like that...
<3> mark105: The proper C++ way would be to use std::string
<3> But since that does nto seem to be an option to you, the proper way is to use new to allocate the memory for temp, and return that.
<3> The caller will have to remember to use delete on the pointer you return, though.
<3> An h***le and possibiltiy of error that would be avoided with std::string
<4> oh ok havent learnt that much, this is for a c++ paper im taking at uni
<1> tell your professor that he's creating a talented legion of future exploitable code authors
<4> lol ok
<3> Well...
<1> they really should start with ***embly, imo
<3> Wether you've learned it or not, if you've got a minimum of pride and self-respect, try writing corect code. =P
<1> to the extend allowed to get you to p***
<1> you'd be surprised how often professors don't like to be shown they're wrong
<1> time to go find some food
<3> I wouldn't be surprised that much, I remember losing points for making a teacher's code more correct. =/
<1> oh, i should probably run to home depot too
<1> gotta get a rug pad for the new furniture arriving tomorrow
<1> which will promptly be destroyed by the cats
<4> so what your saying is my function is a pointer so when it ends i loose whats in it?
<3> Huh...
<3> I'm saying char temp[80] is a pointer to a local array of 80 characters.
<4> yup
<3> But since it's local, the memory gets freed up when you exit the function's scope.
<4> ok
<3> And you'r returning a pointer to that memory location.
<4> oh ok
<3> Either use char *temp = new char[80], or put the resultign substring in a std::string before returning it. You'D ahve to change the function signature though, and your teacher msot likely won'T like that.
<5> arrays are almost, but not quite, like pointers
<4> no he wont we have to use that function sig
<3> Well then, using new is your only choice.
<3> Also...
<5> mark105: return values must either be a value-type (like int) or a handle (pointer or reference) to something that exists independently of the function, automatic variables don't meet that requirement
<3> Your stringlen fucntion is incorrect, if ou use the standard definition of a C string
<4> no doubt
<3> You search for *p == 0, while you should be looking for *p == '\0'
<5> iostream.h doesn't exist in the c++ standard either
<5> DrkMatter: same thing



<0> Heheh
<5> however, it's NUL or nul, the ascii name for character zero
<5> NULL is the null pointer constant and is completely different
<1> have to use that function sig? hahaha
<1> it's fine for "C"
<1> which is what half this stuff is
<5> and char temp[80] = {0}; will zero out the array for you, no need for a loop and repetitive magic numbers
<3> Well, also... Your for loop in there (stringLen) has really ought to be a while loop.
<5> I don't see why you'd say that
<3> That it'S ought to eb a while?
<5> just because you can use a while loop instead of a for loop doesn't mean you should
<5> yes
<1> also, why is it returning i + 1?
<5> if my error correcting engrish parser read what you typed correctly :P
<3> Look at the condition. Semantically, for loops are for loops when you know how many times you'Re going to loop.
<5> that's one use, but not the only valid one
<3> ...
<4> well i have errors now but nothing comes out yet
<5> there are lots of times where you don't know in advance
<3> Well, I could write every single one of my loops as a for or as a while, if I wanted to.
<1> str[i] = temp[x]; ?
<5> a common example is for ( std::string line; getline( std::cin, line ); ) { process( line ); }
<3> But there's an established meaning for each.
<5> DrkMatter: exactly, a loop with distinct initial (or empty), condition, and increment parts is, without examining further qualification, and excellent candidate for a for loop
<6> for (int i = getstart(); i != endCondition(); ++i) { doStuff(); } // No idea how many loops will occur here
<1> Solamente!
<1> is the ****!
<5> DrkMatter: the established meaning for 'for' is distinct parts, and for 'while' is a single expression, expressions with side-effects in a while loop can very, very easily make it buggy and less readable
<5> just look at all the different tools that detect ***ignment in loop conditions if you don't believe that
<1> ****ing cops!
<7> back
<7> what's the topic?
<8> Solamente how it could be break with that loop.
<5> vawjr: http://www.noidea128.org/sourcefiles/15874.html
<8> endcontiditon should return 1 confusing somehow :/
<6> meyrn: When the value of i matches the return value of endCondition
<1> seems like they have fundraisers every other week heh
<1> once you give people money, they hound you for more
<7> where do we start??
<5> peterhu: I hear the people that show up for jury duty get more summons too
<5> vawjr: start = ... 0; // line 49 :P
<8> Solamente hm i didn't understand exactly
<1> i have yet to get summons
<1> but i'm fairly confident i'd be excused
<7> I'm not all that fond of lines 9-20
<1> they don't want independent thinkers on jury
<5> me neither, but I've been moving every couple years
<1> and if they did, i would show up dressed like hitler or something
<1> my time is worth more than 8 dollars an hour
<5> I liked the court and jury system in _the moon is a harsh mistress_
<7> Kniht Heinlein had a lot of good ideas about "governments"
<5> indeed
<1> the fact that police and rescue need to raise funds constantly is troubling
<1> where the **** do our taxes actually go?
<1> i'm curious
<7> to pay bribes to the politicians
<5> the taxes go to the depts., the donations go to the fundraising companies
<1> well, that was a given
<5> some have 95% or higher fundraiser 'costs'
<1> well, these were the cops themselves
<1> i've seen firefighters on street corners
<8> what's fundraiser anyway
<1> asking for the change in your car!
<1> i gave them everything i had
<5> I give money to the salvation army, usually $1-5 bucks each time they're outside the store
<1> agencies like these should not be in need of cash
<5> and we had other groups do that in WI
<5> but i've only seen the sa here
<5> yeah, 1-5 isn't much, but I was working at some of those grocery stores, and so it was 5-25/week
<1> the roads are crap, there's even a ****ing 15 mile long *toll road* that constantly raises prices, the schools are crap, every important agency is strapped for cash, yet i still pay $500 a year in vehicle taxes, and $500 a month in real estate taxes
<1> seriously, where is this money going?
<5> we're fighting for democracy, don't you know?
<5> halliburton needs that money to repair the oil pumps


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #c++
or
Go to some related logs:

#teens
#chatzone
#php
#c++
#java
#java
#linux
php autopostback -asp -net -.net -vb.net
ropository mandriva
#java



Home  |  disclaimer  |  contact  |  submit quotes