|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
|
On October 31 2014 23:32 Nesserev wrote: EDIT2: Question to the C wizards in this thread. If nothing is returned in a non-void function (like in this case), no compiler warnings seems to be given. Why? And what does it return, null?
if you don't return anything, if there's an assignment for the expected return i think the default behavior is to return the address of the function and cast to the assignment type.
(edit: hey sweet i got it right almost? is it just 0 or the function?)
|
s is a pointer, so it will have a non-zero value pointing to a memory cell somewhere.
!s is false unless s was NULL. So when your function is passed a pointer that points to an empty string, it doesn't fall into that if statement.
This is similar to your problem with the while loops in your strjoin, maybe refresh your understanding of pointers?
|
On October 31 2014 23:47 Alzadar wrote: Your strlen can't deal with an empty string.
the first line of the while loop (while s1[index]) deals with empty string fine.
|
You also should read up on the implicit <type> to bool casts C does, as frequently observed in if/while conditional statements. For example:
if(!s) implicity casts the pointer s to bool equivalent to if(s == NULL)
if(!*s) implicity casts the char that s points to to bool equivalent to if(*s == '\0')
|
On November 01 2014 00:19 Blisse wrote:Show nested quote +On October 31 2014 23:47 Alzadar wrote: Your strlen can't deal with an empty string. the first line of the while loop (while s1[index]) deals with empty string fine.
Oh that's true actually, I misunderstood what the first check was trying to do and didn't really consider the loop. Never mind me, I'll go back to Tcl.
spinesheath I think you have some extra bangs there.
|
On November 01 2014 00:10 Blisse wrote:Show nested quote +On October 31 2014 23:32 Nesserev wrote: EDIT2: Question to the C wizards in this thread. If nothing is returned in a non-void function (like in this case), no compiler warnings seems to be given. Why? And what does it return, null? if you don't return anything, if there's an assignment for the expected return i think the default behavior is to return the address of the function and cast to the assignment type. (edit: hey sweet i got it right almost? is it just 0 or the function?) Pretty sure it'll return whatever happens to be in EAX at the time (or however your compiler's calling convention does return values) - it's guaranteed UB though Your compiler should definitely give a warning if you have -Wall or equivalent on.
|
On November 01 2014 00:24 Alzadar wrote:Show nested quote +On November 01 2014 00:19 Blisse wrote:On October 31 2014 23:47 Alzadar wrote: Your strlen can't deal with an empty string. the first line of the while loop (while s1[index]) deals with empty string fine. Oh that's true actually, I misunderstood what the first check was trying to do and didn't really consider the loop. Never mind me, I'll go back to Tcl. spinesheath I think you have some extra bangs there. Nah man, you're still right kinda, I mixed the check for a pointer to NULL and the check for an empty string. Definitely some understanding issues, although I know all that :/
|
re: pointer understanding, I know it helped me a lot to write
char* c instead of char *c
Just don't do this when declaring multiple variables on one line.
|
On November 01 2014 00:24 Alzadar wrote: spinesheath I think you have some extra bangs there. Oh wow, that was so stupid of me. Not only is it much simpler now, but also if I wanted to show how the negation works together with the implicit cast I should have written the following instead: if(!(s != NULL))
|
Crossposted from SFW funny pictures thread:
|
Hey guys is anyone able to give me a hand with this?
*my code isn't 100% the same but if I can fix it here I can fix it on my end*
http://jsfiddle.net/be7tfczs/2/
Basically I want to be able to select a link and have the information pop up from imdb, but the code I have seems to use the first instance of "movie" all the time instead of the value associated with the link. I'm sure the solution is simple and I'm just not getting it
|
On November 01 2014 17:14 JD. wrote:Hey guys is anyone able to give me a hand with this? *my code isn't 100% the same but if I can fix it here I can fix it on my end* http://jsfiddle.net/be7tfczs/2/Basically I want to be able to select a link and have the information pop up from imdb, but the code I have seems to use the first instance of "movie" all the time instead of the value associated with the link. I'm sure the solution is simple and I'm just not getting it http://api.jquery.com/html/
Description: Get the HTML contents of the first element in the set of matched elements.
So basically, your $('.movie;).html() call just finds the first match and stops.
I think what you want is $(this).text()
|
Beautiful, thanks! I knew it was something simple haha.
|
The Pros and Cons of Agile or Waterfall programming method of choice.
I looked up the P's and Q's about this, but I'd like to hear what TL'ers think. Does Agile suit you as the way for programming or do you need to have a strict plan? I'd like to hear what you folks think are the Pro's and Con's of each and what drives you to this way of programming.
Cheers
|
I've learned that strict plans usually fail. Customers tend to change their mind on stuff as you go and then you have to go back to stuff you already did and change it, creating delays that keep adding up until it becomes unmanagable as you have to skip stuff or do it poorly to meet the deadlines. With agile it's much easier to accomodate the unexpected. Like this last week, project was scheduled for deployment but 1 day before that the customer submitted 8 or so changes. No biggie.
http://www.agilenutshell.com/agile_vs_waterfall
|
Agile is good for shit that you don't need long planning periods to build. Like tech start-up products. Or mobile apps. Or websites. Probably not great for building a spaceship. Or building a bridge. They're good for shit that you want to get out super quickly and get feedback. Like tech start-up products. Or mobile apps. Or websites. Probably not great for building bridges. Or building spaceships.
|
Agile methodology is just different terminology for what is commonly done many other ways already. Most ways of developing something involve on the fly changes and maybe shuffling things around. Just seems like calling a car an automobile to me your not really doing anything new.
|
you're gonna be a terrible automobile accessory salesman snakeeyez.
|
I want to get back into C++ development since the C++11 changes intrigue me and I haven't done any C++ work in ages and recently noticed how rusty I am in that regard. That is why I'm wondering which IDE is common these days. Back in the day I've used VIM and wrote Makefiles by hand and such, but these days I'd prefer to use a full IDE instead, so which IDE (using Windows) would you recommend?
|
|
|
|