| Banned
Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,695
| silly holy wars If you thought the Emacs vs. vi war was blown out of proportion, "you ain't seen nothin' yet', because that's -nothing- compared to the for vs. while war! :-P Quote:
(11:49:27 PM) Josh: that's the second edition of a VERY famous book
(11:49:52 PM) Clint: o
(11:50:29 PM) Josh: ever wondered what the exact syntax of the strlen function is?
(11:50:41 PM) Clint: no
(11:50:46 PM) Josh: Code: /* strlen: return length of s */
int strlen(char s[])
{
int i;
while (s[i] != '\0')
++i;
return i;
}
(11:50:59 PM) Josh: that's the original version of the function
(11:51:09 PM) Josh: well, original of the ASCII C, anyways
(11:51:17 PM) Clint: o
(11:51:24 PM) Josh: it's what we've been using for about 20 years now
(11:51:38 PM) Clint: o
(11:51:45 PM) Josh: I wonder why they didn't use a for loop instead
(11:51:59 PM) Josh: I guess it doesn't really matter
(11:52:01 PM) Clint: because
(11:52:05 PM) Josh: while would be more efficient
(11:52:08 PM) Josh: better syntax
(11:52:11 PM) Clint: for loops are for when you know the length already
(11:52:22 PM) Josh: not necessarily
(11:52:25 PM) Clint: yes
(11:52:33 PM) Clint: necessarily
(11:52:37 PM) Clint: that is what a for is for
(11:52:48 PM) Clint: you need to learn how to use them correctly
(11:52:52 PM) Clint: go to college
(11:52:54 PM) Josh: they could have done this: Code: int i;
for (i=0;s[i]!='\0';++i);
(11:53:11 PM) Clint: no
(11:53:21 PM) Clint: a while loop is correct
(11:53:27 PM) Josh: it doesn't really matter
(11:53:29 PM) Josh: it does the same thing
(11:53:35 PM) Clint: but while is better for it
(11:53:51 PM) Josh: how so? :-\
(11:53:56 PM) Clint: GO TO COLLEGE
(11:53:59 PM) Josh: heh
(11:54:06 PM) Clint: look up the difference between them
(11:54:24 PM) Clint: look in the book that I gave you
(11:57:17 PM) Josh: compile this: Code: #include <stdio.h>
int strlen(char s[])
{
int i;
for (i=0;s[i]!='\0';++i);
return i;
}
main()
{
printf("%i",strlen("testing"));
}
(11:57:26 PM) Josh: absolutely nothing wrong with it ;)
(11:57:40 PM) Clint: you are impossible
(11:57:42 PM) Clint: go to college
(11:57:51 PM) Clint: you will learn more there than you will learn on your own
(11:58:00 PM) Josh: and learn to be narrow-minded and only think the ways they want you to think?
(11:58:08 PM) Josh: there's nothing wrong with using for
(11:58:22 PM) Clint: it is inefficient and sloppy
(11:58:28 PM) Clint: it is not what it was made for
(11:58:29 PM) Josh: inefficient?
(11:58:31 PM) Josh: heh
(11:58:45 PM) Josh: it takes fewer bytes to store
(11:58:48 PM) Clint: go to college
(11:58:56 PM) Josh: you're weird :P
(11:59:05 PM) Clint: I think that you are
(11:59:14 PM) Josh: there's nothing wrong with either ways
(11:59:37 PM) Josh: *way
(11:59:38 PM) Clint: you just dont know the difference
(11:59:57 PM) Josh: they're there to use them to your own advantage
(05/10/2007 12:00:12 AM) Josh: there's no reason to narrow our minds to only think the way things were originally intended
(12:00:12 AM) Clint: but you are using them wrong
(12:00:18 AM) Josh: that leaves no room for creativity :)
(12:00:25 AM) Clint: you can be creative
(12:00:34 AM) Clint: but that is not how it was made to be used
(12:01:08 AM) Josh: they both work, so who cares?
(12:01:30 AM) Clint: I wont help you with your im thing
(12:01:46 AM) Josh: because I like for loops? :))
(12:02:04 AM) Josh: 8-}
(12:02:30 AM) Clint: because you dont know how to use them correctly
(12:02:44 AM) Josh: and what exactly is your definition of "correctly"?
(12:02:54 AM) Clint: as they were intended
(12:03:01 AM) Clint: to be used
(12:03:34 AM) Josh: so you would never use Emacs to check your e-mail, or Pidgin as a spell checker while you're working on a document in a plain text editor?
(12:04:11 AM) Clint: that is totally different
(12:04:32 AM) Josh: they both work
(12:04:41 AM) Clint: you are self taught.... not everything that you do or know is correct
(12:04:47 AM) Josh: heh
(12:04:53 AM) Clint: in fact most of it is wrong
(12:04:57 AM) Josh: :P
(12:04:57 AM) Clint: go to college
(12:05:00 AM) Clint: learn somethingg
(12:05:01 AM) Clint: g
(12:05:34 AM) Josh: like how to nit at the silliest things?
(12:05:53 AM) Clint: go to college
(12:06:18 AM) Clint: if you knew how to use them correctly then I wouldnt be nitting
(12:06:55 AM) Josh: can you point out a specific problem with it?
(12:07:06 AM) Josh: other than the fact that you prefer while
(12:07:34 AM) Clint: a while loop was created for this type of situation
(12:08:05 AM) Clint: for loops were created so you can loop things for a known amount of times
(12:08:08 AM) Clint: like 10 times
(12:08:26 AM) Clint: a while loop can execute 0-however many times it needs to
(12:09:16 AM) Clint: I know that a for loop can be used for it but it is not what it was made for
(12:09:27 AM) Josh: the only difference is that for has two extra places for a small statement. What you do with those statements is completely up to the programmer
(12:09:40 AM) Clint: you are impossible
(12:09:45 AM) Clint: you dont know what you are talking about
(12:09:52 AM) Clint: go to college and you might learn something
(12:10:20 AM) Josh: if that's the kind of thing I'm supposed to learn about in college, then I could find better ways to spend $15,000 a year
(12:10:33 AM) Clint: you dont know what you are talking about
(12:10:36 AM) Clint: I am getting off here
(12:10:40 AM) Josh: lol
(12:10:43 AM) Clint: you think that you know everything about it
(12:10:51 AM) Clint: you dont know anything about it
(12:11:02 AM) Josh: 8-}
| |