22062010
1 <pedro3005> [Jun 22 17:06:12] juju2143, I'm so sorry to be bothering you yet again but ping
2 <juju2143> [Jun 22 17:06:40] pong?
3 <pedro3005> [Jun 22 17:07:40] well, to publicize the class, we need either a short description or even maybe something about your experience related to C#.. something to say, basically, to go towards publicizing
4 <pedro3005> [Jun 22 17:14:53] juju2143, ^
5 <juju2143> [Jun 22 17:20:43] ah ok
6 <juju2143> [Jun 22 17:21:14] bah this is an introduction to C#
7 <juju2143> [Jun 22 17:22:11] learnt it at school
8 <juju2143> [Jun 22 17:22:13] etc.
9 <pedro3005> [Jun 22 19:03:43] bgs100, was there any homework?
10 <bgs100> [Jun 22 19:04:28] one sec
11 * bgs100 [Jun 22 19:05:34] attempts to recall...
12 <bgs100> [Jun 22 19:06:04] pedro3005, Don't think so
13 <pedro3005> [Jun 22 19:06:11] hah!
14 <bgs100> [Jun 22 19:06:17] Hiya seidos
15 <pedro3005> [Jun 22 19:06:20] bgs100, did you continue the class after I left?
16 <bgs100> [Jun 22 19:06:52] Not really
17 <pedro3005> [Jun 22 19:07:19] ok
18 <bgs100> [Jun 22 19:07:30] We talked about prine based number systems and binary
19 <pedro3005> [Jun 22 19:08:15] hey seidos
20 <bgs100> [Jun 22 19:09:34] brb
21 <bgs100> [Jun 22 19:10:53] back
22 <bgs100> [Jun 22 19:10:55] Sooooooo
23 <bgs100> [Jun 22 19:11:06] Are we all ready to begin?
24 <bgs100> [Jun 22 19:11:08] seidos, pedro3005 ?
25 <pedro3005> [Jun 22 19:11:21] ARE YOU READY
26 <pedro3005> [Jun 22 19:11:27] :p
27 <pedro3005> [Jun 22 19:11:29] ready
28 <bgs100> [Jun 22 19:11:31] TO ROCK?!
29 <pedro3005> [Jun 22 19:11:47] noo... >:(
30 <bgs100> [Jun 22 19:11:57] I WANNA ROCK! YEAAHH ROCK YEEAHH ROCK YEEAHH
31 <bgs100> [Jun 22 19:12:02] DA NA NA
32 <pedro3005> [Jun 22 19:12:11] bgs100, http://www.youtube.com/watch?v=2JSgjQHPrTc
33 <bgs100> [Jun 22 19:12:12] *wicked guitar solo*
34 <bgs100> [Jun 22 19:12:27] oh
35 <bgs100> [Jun 22 19:12:29] :P
36 <bgs100> [Jun 22 19:12:46] seidos, ?
37 <bgs100> [Jun 22 19:14:00] .........
38 <bgs100> [Jun 22 19:14:12] I'll assume seidos will be here shortly
39 <bgs100> [Jun 22 19:14:16] Now
40 <bgs100> [Jun 22 19:14:23] Without Further Ado
41 <pedro3005> [Jun 22 19:14:33] THE C CLASS
42 <bgs100> [Jun 22 19:14:54] -=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-= MAY ZE C CLASS =-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-
43 <bgs100> [Jun 22 19:15:02] -=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-= BEGIN =-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-
44 <bgs100> [Jun 22 19:15:29] So ya
45 <bgs100> [Jun 22 19:15:43] Now
46 <bgs100> [Jun 22 19:15:51] seidos, pedro3005 You pretty much know the base language
47 <bgs100> [Jun 22 19:16:01] So give yourself a hearty pat on the back
48 * pedro3005 [Jun 22 19:16:04] dances around the room
49 <bgs100> [Jun 22 19:16:09] or that
50 <bgs100> [Jun 22 19:16:22] whatever *float*s your boat xD
51 <bgs100> [Jun 22 19:16:48] Get it? Get it? *elbows pedro3005*
52 <pedro3005> [Jun 22 19:16:54] you've used that one before
53 <bgs100> [Jun 22 19:16:59] No
54 <pedro3005> [Jun 22 19:17:04] yes you have
55 <bgs100> [Jun 22 19:17:05] before I said No pun intended
56 <bgs100> [Jun 22 19:17:13] Thsi time it's completely intended
57 <pedro3005> [Jun 22 19:17:14] well, still
58 <bgs100> [Jun 22 19:17:18] This*
59 <bgs100> [Jun 22 19:17:49] So
60 <bgs100> [Jun 22 19:17:55] Now, we will be focusing upon:
61 <bgs100> [Jun 22 19:18:05] ***THE STANDARD LIBRARY***
62 <bgs100> [Jun 22 19:18:09] *Angels sing*
63 <pedro3005> [Jun 22 19:19:19] I read it more in a devilish frightening tone
64 <bgs100> [Jun 22 19:19:28] ...
65 <bgs100> [Jun 22 19:19:34] Well fix that
66 <bgs100> [Jun 22 19:20:11] The standard library is sort of like the modules that Python always comes with. If it's normal C (e.g. your not building stuff for a kernel or embedded device), you'll have the standard library.
67 <bgs100> [Jun 22 19:21:43] So
68 <bgs100> [Jun 22 19:21:57] As you (*pings pedro3005 and seidos again*) know,
69 <bgs100> [Jun 22 19:22:25] we have been using the standard library in every example thus far.
70 <pedro3005> [Jun 22 19:22:32] yes
71 <bgs100> [Jun 22 19:23:05] There's not that much you can do without the standrad library, unless you use assembly with C.
72 <bgs100> [Jun 22 19:23:20] stdio.h is part of the standard library
73 <bgs100> [Jun 22 19:24:17] pedro3005, Your book should have a reference to the standard library in Appendix B
74 <pedro3005> [Jun 22 19:24:43] yes
75 <bgs100> [Jun 22 19:25:07] For seidos: http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html looks pretty good
76 <pedro3005> [Jun 22 19:25:25] stdio, ctype, string, math, stdlib, assert, stdarg, setjmp, signal, time, limits, float
77 <bgs100> [Jun 22 19:26:17] anyway.
78 <bgs100> [Jun 22 19:26:30] I was thinking that today, we would start with string.h
79 <bgs100> [Jun 22 19:27:11] string.h consists of functions useful for doing things with strings, as the name Oh-So-Discreetly implies
80 <bgs100> [Jun 22 19:28:05] So
81 <bgs100> [Jun 22 19:28:41] Allocating char pointers for strings yourself was mentioned yesterday.
82 <bgs100> [Jun 22 19:28:57] However,
83 <bgs100> [Jun 22 19:29:06] if you allocate it yourself and such,
84 <bgs100> [Jun 22 19:29:13] how can you assign it to a string nicely?
85 <bgs100> [Jun 22 19:29:23] If you do:
86 <bgs100> [Jun 22 19:29:37] char *string = malloc(5);
87 <bgs100> [Jun 22 19:29:46] later saying:
88 <bgs100> [Jun 22 19:29:52] string = "book";
89 <bgs100> [Jun 22 19:29:56] obviously won't work
90 <bgs100> [Jun 22 19:30:11] since it just changes the address string has.
91 <pedro3005> [Jun 22 19:30:16] string = {'b', 'o', 'o', 'k'}
92 <pedro3005> [Jun 22 19:30:17] ?
93 <Snova> [Jun 22 19:30:21] it's rather not obvious at all
94 <Snova> [Jun 22 19:30:26] no
95 <bgs100> [Jun 22 19:30:27] Same thing, except without a '\0'
96 <bgs100> [Jun 22 19:30:38] Snova, It's a reassignment.
97 <bgs100> [Jun 22 19:30:49] *shrugs*
98 <Snova> [Jun 22 19:30:53] there is no way to assign to an array like that
99 <bgs100> [Jun 22 19:30:56] Also, hai
100 <Snova> [Jun 22 19:31:01] hello
101 <pedro3005> [Jun 22 19:31:06] did you read the malloc part earlier?
102 <Snova> [Jun 22 19:31:12] uh, yes?
103 <Snova> [Jun 22 19:31:43] malloc isn't relevant to this point; you can not assign the contents of an array except when initially declaring it
104 <pedro3005> [Jun 22 19:31:44] still no way?
105 <bgs100> [Jun 22 19:31:50] Oh yeah
106 * bgs100 [Jun 22 19:31:55] facepalms
107 <Snova> [Jun 22 19:31:59] i.e. int x[5] = {1, 2, 3, 4, 5}; will work but you can't change the whole thing later on
108 <bgs100> [Jun 22 19:32:15] Well, now there's two reasons it would not work. xP
109 <pedro3005> [Jun 22 19:32:41] Snova, isn't there someway to tell it to "forget" about the old x and just declare it again?
110 <Snova> [Jun 22 19:32:42] "char* string = malloc(5); string = "book";" doesn't change the contents of the original allocation; it changes the pointer "string" to reference the constant string "book"
111 <Snova> [Jun 22 19:32:45] it's also a memory leak
112 <Snova> [Jun 22 19:32:48] pedro3005: no
113 <bgs100> [Jun 22 19:33:02] Snova, That was my point...
114 <pedro3005> [Jun 22 19:33:29] god I hate C
115 <pedro3005> [Jun 22 19:33:33] :P
116 <bgs100> [Jun 22 19:33:34] :|
117 <pedro3005> [Jun 22 19:34:37] you can't do anything
118 <pedro3005> [Jun 22 19:34:41] but go on
119 <bgs100> [Jun 22 19:34:43] ...
120 <Snova> [Jun 22 19:34:56] C has been called a "portable assembly"
121 <bgs100> [Jun 22 19:35:17] pedro3005, Apparently, you can, considering many other languages' interpreters/compilers are written in it...
122 <bgs100> [Jun 22 19:35:46] But Aaaannnyyywaaayyy
123 <bgs100> [Jun 22 19:35:54] So yeah
124 <bgs100> [Jun 22 19:37:05] Anyway
125 <bgs100> [Jun 22 19:37:10] You could do this:
126 <bgs100> [Jun 22 19:37:21] char *string = malloc(5);
127 <bgs100> [Jun 22 19:37:36] strcpy(string, "book");
128 <bgs100> [Jun 22 19:37:40] Correct, Snova?
129 <Snova> [Jun 22 19:37:52] yes
130 <bgs100> [Jun 22 19:37:57] Okay
131 <bgs100> [Jun 22 19:38:01] Good :p
132 <bgs100> [Jun 22 19:39:07] pedro3005, (since seidos doesn't seem to be present) strcpy take two char pointers/arrays and copies the contents of the second (including the '\0') into the first.
133 <pedro3005> [Jun 22 19:39:38] so basically it does string[0] = 'b'; etc?
134 <bgs100> [Jun 22 19:39:46] strcpy = string copy, as you probably guessed.
135 <Snova> [Jun 22 19:39:53] pedro3005: pretty much
136 <pedro3005> [Jun 22 19:40:13] okay
137 <bgs100> [Jun 22 19:40:13] pedro3005, Or rather, string[0] = secondstring[0], but in this case yeah
138 <bgs100> [Jun 22 19:41:09] Also
139 <bgs100> [Jun 22 19:41:37] I should mention that for many str<blank> functions there are also strn<blank> functions,
140 <pedro3005> [Jun 22 19:42:09] what does that mean?
141 <bgs100> [Jun 22 19:42:21] I'm typing :P
142 <bgs100> [Jun 22 19:42:37] Those take an extra argument that makes it only do whatever for n characters
143 <bgs100> [Jun 22 19:42:41] For example,
144 <bgs100> [Jun 22 19:43:04] strncpy will only copy n characters to the first string
145 <bgs100> [Jun 22 19:44:08] From the manpage for strcpy/strncpy: "The strncpy() function is similar, except that at most n bytes of src are copied."
146 <bgs100> [Jun 22 19:44:22] src being the second string
147 <bgs100> [Jun 22 19:44:28] pedro3005, Okay?
148 <pedro3005> [Jun 22 19:44:31] example?
149 <bgs100> [Jun 22 19:45:05] char *string = malloc(4);
150 <bgs100> [Jun 22 19:45:17] strncpy(string, "book", 4);
151 <bgs100> [Jun 22 19:45:19] HOWEVER
152 <bgs100> [Jun 22 19:45:27] This will cut off the '\0' at the end
153 <pedro3005> [Jun 22 19:45:57] oh, so always +1
154 <bgs100> [Jun 22 19:46:06] pedro3005, I might be used to make sure that the function doesn't copy past the first string's actual length.
155 <bgs100> [Jun 22 19:46:15] pedro3005, er that's not the point :p
156 <bgs100> [Jun 22 19:46:21] s/I/It/
157 <pedro3005> [Jun 22 19:46:41] oh, ok
158 <pedro3005> [Jun 22 19:46:52] this is somewhat confusing but alright
159 <bgs100> [Jun 22 19:47:34] Okay
160 <bgs100> [Jun 22 19:47:43] Next, we have strcat
161 <bgs100> [Jun 22 19:48:21] Example:
162 <bgs100> [Jun 22 19:48:46] char *string = malloc(9);
163 <bgs100> [Jun 22 19:49:00] strcpy(string, "book");
164 <bgs100> [Jun 22 19:49:09] strcat(string, "club");
165 <bgs100> [Jun 22 19:49:16] string ends up being "bookclub"
166 <pedro3005> [Jun 22 19:49:54] so it adds it before the '\0' and makes sure there is not two '\0' at the end?
167 <bgs100> [Jun 22 19:50:25] Yeah, pretty much.
168 <bgs100> [Jun 22 19:50:41] Or rather just overwrites the first '\0' with the first character of the second string
169 <bgs100> [Jun 22 19:50:54] and then copies the second strings '\0'
170 <pedro3005> [Jun 22 19:51:32] I see
171 <bgs100> [Jun 22 19:51:40] But yeah, it appends string2 to string1, and if they're "normal" strings there won't be two '\0''s
172 <bgs100> [Jun 22 19:51:47] So
173 <bgs100> [Jun 22 19:51:55] Oh
174 <bgs100> [Jun 22 19:52:02] And there's a "n" version of that too
175 <bgs100> [Jun 22 19:52:15] Where only "n" characters from string2 are appended
176 <bgs100> [Jun 22 19:53:17] Okay
177 <bgs100> [Jun 22 19:53:18] strchr
178 <pedro3005> [Jun 22 19:53:18] ok
179 <bgs100> [Jun 22 19:54:38] char *string = malloc(7);
180 <bgs100> [Jun 22 19:55:09] strcpy(string, "cookie");
181 <bgs100> [Jun 22 19:55:31] char *otherstring = strchr(string, 'o');
182 <bgs100> [Jun 22 19:55:42] otherstring should now be the string "ookie"
183 <bgs100> [Jun 22 19:55:55] However
184 <bgs100> [Jun 22 19:56:01] Well
185 <bgs100> [Jun 22 19:56:02] First
186 <bgs100> [Jun 22 19:56:44] pedro3005, strchr returns a pointer to the first occurrence of the character ('o') in the string
187 <bgs100> [Jun 22 19:57:02] Okay?
188 <bgs100> [Jun 22 19:57:17] ...
189 <pedro3005> [Jun 22 19:57:23] brb, I have to... brush my teeth
190 <bgs100> [Jun 22 19:57:27] ............
191 <bgs100> [Jun 22 19:57:34] well okay then
192 <bgs100> [Jun 22 19:57:45] Don't take too long :P
193 <bgs100> [Jun 22 19:57:48] (jk)
194 <pedro3005> [Jun 22 19:59:12] bgs100, back
195 <bgs100> [Jun 22 19:59:52] okay
196 <bgs100> [Jun 22 19:59:59] pedro3005, So Okay about strchr?
197 <pedro3005> [Jun 22 20:00:09] so strchr copies it starting from 'o'?
198 <bgs100> [Jun 22 20:00:14] Uhh
199 <bgs100> [Jun 22 20:00:23] I was about to get to that...
200 <bgs100> [Jun 22 20:00:26] It doesn't copy it
201 <pedro3005> [Jun 22 20:00:41] oh
202 <pedro3005> [Jun 22 20:00:41] right
203 <pedro3005> [Jun 22 20:00:45] it returns it
204 <bgs100> [Jun 22 20:00:56] If you changed string more than the first character, otherstring would change too
205 <bgs100> [Jun 22 20:01:01] And vice versa
206 <pedro3005> [Jun 22 20:01:17] oh, because it returns a poinnnnnnter
207 * bgs100 [Jun 22 20:01:31] gives pedro3005 a star
208 <bgs100> [Jun 22 20:01:36] well
209 <bgs100> [Jun 22 20:01:38] not quite
210 <bgs100> [Jun 22 20:01:45] If it copied it,
211 <bgs100> [Jun 22 20:01:53] It would still be returning a pointer
212 * bgs100 [Jun 22 20:02:00] takes away half of the star
213 <pedro3005> [Jun 22 20:02:02] just a different one
214 <bgs100> [Jun 22 20:02:15] Yea
215 <bgs100> [Jun 22 20:03:59] Also
216 <bgs100> [Jun 22 20:04:04] There is strrchr
217 <bgs100> [Jun 22 20:04:20] It returns a pointer to the *last* occurence of a char
218 <bgs100> [Jun 22 20:04:22] Like
219 <bgs100> [Jun 22 20:04:26] If we had said:
220 <bgs100> [Jun 22 20:04:35] char *otherstring = strrchr(string, 'o');
221 <bgs100> [Jun 22 20:04:37] instead
222 <bgs100> [Jun 22 20:04:44] otherstring would be "okie"
223 <bgs100> [Jun 22 20:04:52] BTW
224 <bgs100> [Jun 22 20:05:14] Both of these functions return NULL (secretly 0) if they can't find any of that character
225 <bgs100> [Jun 22 20:05:57] pedro3005, 'kay?
226 <pedro3005> [Jun 22 20:06:00] okay
227 <bgs100> [Jun 22 20:06:29] good then
228 <bgs100> [Jun 22 20:06:34] On to strcmp
229 <bgs100> [Jun 22 20:07:07] String compare compares to strings
230 <bgs100> [Jun 22 20:07:47] two*
231 <bgs100> [Jun 22 20:07:53] lexicographically
232 <bgs100> [Jun 22 20:09:20] Which is a very fancy term that means something similar to alphabetical order
233 <bgs100> [Jun 22 20:09:28] pedro3005,
234 <bgs100> [Jun 22 20:09:57] If string1 is "less than" string2 (e.g. "a" < "b"), strcmp returns less than 0
235 <bgs100> [Jun 22 20:10:22] If string1 is "greater than" string2 (e.g. "z" > "y"), strcmp returns more than 0
236 <pedro3005> [Jun 22 20:10:30] what about
237 <pedro3005> [Jun 22 20:10:34] "2" - "a"
238 <pedro3005> [Jun 22 20:10:37] which "wins"?
239 <bgs100> [Jun 22 20:10:49] If the two strings are equal (this is probably what strcmp is primarily used for), it returns 0
240 <bgs100> [Jun 22 20:11:09] pedro3005,
241 <bgs100> [Jun 22 20:11:27] I think it uses your character sets numbers for each
242 <bgs100> [Jun 22 20:11:51] pedro3005, 2 is less than a, methinks
243 <pedro3005> [Jun 22 20:12:11] ok
244 <bgs100> [Jun 22 20:12:13] Ah crap
245 <bgs100> [Jun 22 20:12:17] I have to go for a few
246 <bgs100> [Jun 22 20:12:36] 8sigh*
247 <pedro3005> [Jun 22 20:12:37] it's cool
248 <pedro3005> [Jun 22 20:12:42] I'll program something
249 * bgs100 [Jun 22 20:12:47] shakes fist at parents :P
250 <bgs100> [Jun 22 20:12:52] bai
251 <bgs100> [Jun 22 20:12:57] bbs
252 <bgs100> [Jun 22 20:57:34] Baaack
253 <bgs100> [Jun 22 20:57:39] pedro3005, Ping
254 <pedro3005> [Jun 22 20:57:50] hey
255 <pedro3005> [Jun 22 20:57:53] seidos is here too
256 <pedro3005> [Jun 22 20:59:55] ... I think
257 <pedro3005> [Jun 22 21:01:19] bgs100, >:(
258 <bgs100> [Jun 22 21:05:37] HAI
259 <seidos> [Jun 22 21:05:39] hey
260 <seidos> [Jun 22 21:05:44] I'll have to read the logs of the class
261 <bgs100> [Jun 22 21:05:45] seidos, Read the logs :P
262 <seidos> [Jun 22 21:06:09] 22 isn't posted yet
263 <seidos> [Jun 22 21:06:13] but I'll check back later
264 <pedro3005> [Jun 22 21:08:01] seidos, I have it
265 <pedro3005> [Jun 22 21:08:04] i'll paste them for you
266 <pedro3005> [Jun 22 21:08:50] seidos, http://paste.pocoo.org/show/228767/
267 <pedro3005> [Jun 22 21:09:55] bgs100, do you intend to continue on strings?
268 <bgs100> [Jun 22 21:12:33] Yes
269 <bgs100> [Jun 22 21:12:42] But not right now, unfortunatley :/
270 <seidos> [Jun 22 21:14:47] too bad there aren't videos on learning C
271 <pedro3005> [Jun 22 21:14:55] seidos, there are
272 <seidos> [Jun 22 21:14:57] too bad I can't just upload it all into my brain
273 <seidos> [Jun 22 21:15:08] pedro3005, have you looked at any of them?
274 <pedro3005> [Jun 22 21:15:17] nah
275 <pedro3005> [Jun 22 21:15:24] but I intend to.. some day
276 <pedro3005> [Jun 22 21:15:40] alright bgs100, bye
277 <bgs100> [Jun 22 21:15:50] Well
278 <bgs100> [Jun 22 21:15:52] Actually
279 <bgs100> [Jun 22 21:15:55] i may be able to cintunue
280 <bgs100> [Jun 22 21:16:00] continue*
281 <bgs100> [Jun 22 21:16:15] Anyway
282 <Snova> [Jun 22 21:16:47] bgs100: it's been thirty seconds!
283 <bgs100> [Jun 22 21:17:09] ?
284 <bgs100> [Jun 22 21:17:19] strcmp is most often used for seeing if two strings are equal
285 <Snova> [Jun 22 21:17:44] isn't that the only thing it does? :p
286 <bgs100> [Jun 22 21:18:04] I already talked about that
287 <bgs100> [Jun 22 21:18:32] Look up.
288 <bgs100> [Jun 22 21:19:54] I laready detailed the usage, I'm just adding on.
289 <bgs100> [Jun 22 21:19:57] already*
290 <bgs100> [Jun 22 21:20:02] Anyway
291 <bgs100> [Jun 22 21:20:10] Example:
292 <bgs100> [Jun 22 21:20:18] Ohwait
293 <bgs100> [Jun 22 21:20:25] I should also mention
294 <bgs100> [Jun 22 21:21:02] scanf can read in strings. It will continue until there is whitespace (a space, newline, or tab).
295 <bgs100> [Jun 22 21:21:11] Continuing with the example:
296 <bgs100> [Jun 22 21:21:40] char *string;
297 <bgs100> [Jun 22 21:22:30] er
298 <bgs100> [Jun 22 21:23:25] brb :p
299 <pedro3005> [Jun 22 21:25:23] he'll be back by Christmas
300 <bgs100> [Jun 22 21:26:12] Back
301 <bgs100> [Jun 22 21:26:19] Merry Christmas all!
302 * bgs100 [Jun 22 21:26:31] gives pedro3005 the gift of a bonk on the head
303 <pedro3005> [Jun 22 21:26:42] :P
304 <bgs100> [Jun 22 21:27:21] Okay
305 <bgs100> [Jun 22 21:27:27] char string[21];
306 <bgs100> [Jun 22 21:28:00] printf("ENTER THE SUPER SECRET PASSWORD OR BE EXTERMINATED! ");
307 <bgs100> [Jun 22 21:28:34] scanf("%s", &string);
308 <bgs100> [Jun 22 21:29:04] if (strcmp(string, "happychristmas") == 0) {
309 <bgs100> [Jun 22 21:30:00] puts("CORRECT. YOU MAY NOW LIVE SO YEAH ANYWAY.");
310 <bgs100> [Jun 22 21:30:10] } else {
311 <bgs100> [Jun 22 21:30:29] puts("EXTERMINATE! EXTERMINATE!");
312 <bgs100> [Jun 22 21:30:30] }
313 <bgs100> [Jun 22 21:30:45] sorry for being kind of slow.
314 <pedro3005> [Jun 22 21:30:52] no problem
315 <bgs100> [Jun 22 21:31:02] So, that's strcmp
316 <bgs100> [Jun 22 21:31:26] Hmm
317 <pedro3005> [Jun 22 21:32:04] doesn't C have classes?
318 <pedro3005> [Jun 22 21:32:25] that's probably structs
319 * pedro3005 [Jun 22 21:32:30] fails
320 <bgs100> [Jun 22 21:33:36] Yes, pedro3005 does
321 <pedro3005> [Jun 22 21:33:57] :(
322 <bgs100> [Jun 22 21:34:11] :p
323 <bgs100> [Jun 22 21:34:13] Well
324 <bgs100> [Jun 22 21:35:34] You know, I'm not going to go through every single function in the standard library...
325 <bgs100> [Jun 22 21:35:53] I suggest this:
326 <pedro3005> [Jun 22 21:35:54] bgs100, is it or is it not?
327 <bgs100> [Jun 22 21:36:07] What?
328 <pedro3005> [Jun 22 21:36:11] classes
329 <bgs100> [Jun 22 21:36:15] ...
330 <bgs100> [Jun 22 21:36:26] No, C does not have "classes"
331 <bgs100> [Jun 22 21:36:32] Anyway
332 <bgs100> [Jun 22 21:36:50] For learning about the standard library, I suggest this:
333 <bgs100> [Jun 22 21:37:01] Looking through this page: http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html
334 <bgs100> [Jun 22 21:37:06] And
335 <bgs100> [Jun 22 21:38:06] For more of an in-depth description of a function (usually), related functions, and sometimes examples of usage or implementation, I suggest consulting manpages:
336 <bgs100> [Jun 22 21:38:16] By running: man <name of function>
337 <pedro3005> [Jun 22 21:38:18] bgs100, oh, so that's what stdlib means?
338 <Snova> [Jun 22 21:38:18] pedro3005: no
339 <bgs100> [Jun 22 21:38:26] If that function happens to also be a command
340 <pedro3005> [Jun 22 21:38:43] Snova, ... quick answer huh
341 <pedro3005> [Jun 22 21:38:46] 1 second later
342 <pedro3005> [Jun 22 21:38:48] :P
343 <bgs100> [Jun 22 21:39:09] pedro3005, stdlib does stand for standard library, but stdlib.h does not mean the whole library or any such thing
344 <bgs100> [Jun 22 21:39:26] Also
345 <pedro3005> [Jun 22 21:39:31] so why is it called stdlib.h? they were running out of names?
346 <bgs100> [Jun 22 21:39:41] Uh sure we can go with that :p
347 <bgs100> [Jun 22 21:39:45] *shrugs*
348 <bgs100> [Jun 22 21:39:56] pedro3005, stdlib.h is utility functions
349 <pedro3005> [Jun 22 21:40:24] ok
350 <bgs100> [Jun 22 21:40:29] Perhaps named because it was more in general than the other parts of the standard library
351 <bgs100> [Jun 22 21:40:34] Anyway
352 <bgs100> [Jun 22 21:41:34] If a function happens to have the same name as a command, I suggest trying the 3rd part of manpages: man 3 <functionname>
353 <bgs100> [Jun 22 21:41:37] Okay?
354 <pedro3005> [Jun 22 21:41:51] okay
355 <seidos> [Jun 22 21:42:27] okay
356 <bgs100> [Jun 22 21:42:33] I think that the final parts of this class will be taking questions, giving examples, and assigning, uh, assignments.
357 <seidos> [Jun 22 21:42:34] so now we're on our own
358 <bgs100> [Jun 22 21:42:39] seidos, No.
359 <seidos> [Jun 22 21:42:39] here are the resources for learning
360 <seidos> [Jun 22 21:42:41] go read
361 <bgs100> [Jun 22 21:42:50] :P
362 <seidos> [Jun 22 21:42:51] and implement some of these tools
363 <bgs100> [Jun 22 21:43:02] seidos, Class isn't over yet.
364 <bgs100> [Jun 22 21:43:05] :p
365 <seidos> [Jun 22 21:43:08] oh
366 <bgs100> [Jun 22 21:43:20] There will be a few more
367 <bgs100> [Jun 22 21:43:38] Asking you guys if you have questions or want to go over something again
368 <bgs100> [Jun 22 21:43:49] Maybe a dip into 3rd party libraries
369 <bgs100> [Jun 22 21:43:56] Assignments.
370 <pedro3005> [Jun 22 21:44:01] I'd think we'd benefit from exercising
371 <bgs100> [Jun 22 21:44:11] Yes, thus "Assignments" :p
372 <bgs100> [Jun 22 21:44:24] ...I should probably think of some beforehand
373 * seidos [Jun 22 21:44:36] can't wait until he's graduated from "assignments" to "projects"
374 <pedro3005> [Jun 22 21:44:50] bgs100, maybe the UF beginner challenges?
375 <bgs100> [Jun 22 21:44:50] BTW, about manpages
376 <bgs100> [Jun 22 21:45:04] Yes!
377 * bgs100 [Jun 22 21:45:10] gives pedro3005 star
378 <bgs100> [Jun 22 21:45:12] In fact
379 <bgs100> [Jun 22 21:45:20] I shall link to those next class
380 <bgs100> [Jun 22 21:45:25] or this class
381 <bgs100> [Jun 22 21:45:28] :p
382 <Snova> [Jun 22 21:45:41] seidos: it's coming up with stuff to write that's hard
383 <seidos> [Jun 22 21:46:02] hopefully I can do it
384 <pedro3005> [Jun 22 21:46:04] Snova, well, the hardest part is coming up with how to write it
385 <bgs100> [Jun 22 21:46:10] You can ask me questions about doing things for those, sending me your code that doesn't work/works, etc.
386 <bgs100> [Jun 22 21:46:18] And Snova too, methinks
387 * bgs100 [Jun 22 21:46:39] volunteers Snova :p
388 <Snova> [Jun 22 21:46:43] "sending my your code that works" nothing odder than code that works when it shouldn't, eh?
389 <bgs100> [Jun 22 21:46:50] Lol
390 <bgs100> [Jun 22 21:46:59] I meant just to inspect a nice working product :P
391 <Snova> [Jun 22 21:47:10] I realized that shortly too late :p
392 <bgs100> [Jun 22 21:47:11] But that too, I suppose
393 <pedro3005> [Jun 22 21:47:14] "You are not advanced enough to produce working code! *slaps with ruler*"
394 <bgs100> [Jun 22 21:47:16] Ha
395 * bgs100 [Jun 22 21:47:27] slaps pedro3005 with meterstick
396 <bgs100> [Jun 22 21:47:45] This is a multi-nation/timezone ordeal! :p
397 <pedro3005> [Jun 22 21:47:59] bgs100, do we get bonuses for using 'goto' in every code we write?
398 <bgs100> [Jun 22 21:48:07] pedro3005, Yes!
399 <bgs100> [Jun 22 21:48:13] I will send you a nice present
400 <bgs100> [Jun 22 21:48:19] A hungy raptor.
401 <bgs100> [Jun 22 21:48:21] hungry*
402 <bgs100> [Jun 22 21:49:02] Anyway
403 <bgs100> [Jun 22 21:49:41] So yes, I suggest you try things on your own now, read about things, etc., and use the following lessons as a resource for help and additional learning.
404 <bgs100> [Jun 22 21:50:05] Instead of my lesson plan, it will now be more of *your* lesson plan.
405 <bgs100> [Jun 22 21:50:11] Okay?
406 <pedro3005> [Jun 22 21:50:15] okay
407 * pedro3005 [Jun 22 21:50:20] shakes bgs100's hand
408 * bgs100 [Jun 22 21:50:31] hands pedro3005 a diploma
409 <bgs100> [Jun 22 21:50:44] :P
410 * pedro3005 [Jun 22 21:50:50] frames and hangs it on a wall
411 * bgs100 [Jun 22 21:51:17] says "Good work, pedro. Good work."
412 <bgs100> [Jun 22 21:51:20] :P
413 <bgs100> [Jun 22 21:51:25] Oh and seidos too :D
414 <pedro3005> [Jun 22 21:51:28] bgs100, okay, now Lisp
415 <pedro3005> [Jun 22 21:51:30] :P
416 <bgs100> [Jun 22 21:51:32] YAY
417 <bgs100> [Jun 22 21:51:51] ============ The History of Lisp ============
418 <bgs100> [Jun 22 21:51:53] :P
419 <bgs100> [Jun 22 21:52:01] But anyway
420 <bgs100> [Jun 22 21:52:13] pedro3005, seidos Do you currently have any questions vaguely related to C? :P
421 <seidos> [Jun 22 21:52:25] what language is firefox written in?
422 <seidos> [Jun 22 21:52:44] I asked in #firefox, but they told me to do a google search
423 <bgs100> [Jun 22 21:52:49] http://en.wikipedia.org/wiki/Firefox
424 <bgs100> [Jun 22 21:52:56] Written in C++, JavaScript,[3] CSS,[4][5] XUL, XBL
425 <seidos> [Jun 22 21:52:56] and the question is *vaguely* related to C
426 <bgs100> [Jun 22 21:53:31] seidos, That's probably why they told you to search :P
427 <pedro3005> [Jun 22 21:53:32] bgs100, how different is C++ from C?
428 <bgs100> [Jun 22 21:53:37] pedro3005, Hmm
429 <bgs100> [Jun 22 21:53:39] Well
430 <bgs100> [Jun 22 21:53:50] C++ has a lot of extra stuff
431 <bgs100> [Jun 22 21:54:11] Classes, Templates, The STL, and such
432 <bgs100> [Jun 22 21:54:27] They are close enough that you can use the C standard library in C++
433 <bgs100> [Jun 22 21:54:37] Lots of valid C code is also valid C++
434 <bgs100> [Jun 22 21:54:56] However, C++ does have a slightly stricter type system, so not all C code is valid C++.
435 <bgs100> [Jun 22 21:55:35] g++ (C++ compiler) is part of gcc
436 <pedro3005> [Jun 22 21:55:48] alright
437 <bgs100> [Jun 22 21:56:00] The STL really does add some nice classes
438 <pedro3005> [Jun 22 21:56:06] let me start the beginner's challenges then
439 <bgs100> [Jun 22 21:56:11] Like strings, which you can add to each with +/+=
440 <bgs100> [Jun 22 21:56:22] Er, a string class
441 <bgs100> [Jun 22 21:56:26] pedro3005, Okay
442 <bgs100> [Jun 22 21:56:37] pedro3005, Would you paste the link here?
443 <pedro3005> [Jun 22 21:56:44] http://ubuntuforums.org/showthread.php?p=5499486
444 <pedro3005> [Jun 22 21:56:47] this has _some_ of them
445 <pedro3005> [Jun 22 21:56:49] but not all
446 <pedro3005> [Jun 22 21:57:00] the others you'll have to search for it because I am very lazy
447 <bgs100> [Jun 22 21:57:03] Yeah, some more were later created
448 <pedro3005> [Jun 22 21:58:15] 2 looks interesting
449 <bgs100> [Jun 22 21:58:53] Also
450 <bgs100> [Jun 22 21:58:55] pedro3005, seidos
451 <bgs100> [Jun 22 21:59:04] Some functions I suggest you look up:
452 <bgs100> [Jun 22 21:59:06] fgets
453 <bgs100> [Jun 22 21:59:10] ungetc
454 <bgs100> [Jun 22 21:59:12] sscanf
455 <bgs100> [Jun 22 21:59:14] sprintf
456 <pedro3005> [Jun 22 21:59:22] bgs100, oohhh yeah.. what about sockets?
457 <bgs100> [Jun 22 21:59:42] *whistles*
458 <pedro3005> [Jun 22 22:00:04] thought you were getting away with it, huh!
459 <seidos> [Jun 22 22:00:09] was that a "walking away whistle", or a "woooow, that's big" whistle?
460 <bgs100> [Jun 22 22:00:11] Those header files aren't part of the standard library
461 <bgs100> [Jun 22 22:00:19] seidos, walking away
462 <bgs100> [Jun 22 22:00:27] Those header files aren't part of the standard library, so I don't have to teach them! :P
463 <bgs100> [Jun 22 22:00:41] But, honestly
464 <seidos> [Jun 22 22:00:51] you don't have to teach anything, for which I am grateful
465 <seidos> [Jun 22 22:01:04] er, that is, I am grateful that you are taking your time to teach us
466 <bgs100> [Jun 22 22:01:08] I would suggest:
467 <bgs100> [Jun 22 22:01:09] http://www.linuxhowtos.org/C_C++/socket.htm
468 <bgs100> [Jun 22 22:01:12] seidos, Lol
469 <bgs100> [Jun 22 22:01:22] You can come to me with any questions
470 <bgs100> [Jun 22 22:01:38] There are man pages for the socket-related functions
471 <bgs100> [Jun 22 22:01:44] as well.
472 <seidos> [Jun 22 22:01:49] oh good god
473 <seidos> [Jun 22 22:01:52] what did I get myself into?
474 <pedro3005> [Jun 22 22:02:00] holy f***
475 <bgs100> [Jun 22 22:02:26] .....
476 <seidos> [Jun 22 22:02:30] it's like <God voice> The client server model </God voice>
477 <bgs100> [Jun 22 22:02:45] LOL
478 * seidos [Jun 22 22:03:05] cowers from *The client server model*
479 <bgs100> [Jun 22 22:03:12] Well, admittedly, "C_C" was in the URL
480 <Snova> [Jun 22 22:03:22] the socket interface more or less comes down to; socket(), connect(), write()
481 <seidos> [Jun 22 22:03:24] okay, that's enough cowering, better start reading
482 <pedro3005> [Jun 22 22:03:27] ... who needs sockets anyway
483 <pedro3005> [Jun 22 22:03:36] :P
484 <Snova> [Jun 22 22:03:41] it's "complicated" to get around language limitations
485 <pedro3005> [Jun 22 22:05:51] bgs100, I keep forgetting things
486 <bgs100> [Jun 22 22:05:56] :|
487 <bgs100> [Jun 22 22:06:05] pedro3005, Quick, where are your car keys?
488 <bgs100> [Jun 22 22:06:06] :p
489 <pedro3005> [Jun 22 22:07:43] nowhere
490 <pedro3005> [Jun 22 22:07:46] I don't have a car
491 <Snova> [Jun 22 22:08:20] you lost that too?
492 <bgs100> [Jun 22 22:08:23] Well, good, at least you remember were those are.
493 <bgs100> [Jun 22 22:08:26] where*
494 <bgs100> [Jun 22 22:08:34] Hahaha
495 <pedro3005> [Jun 22 22:09:04] Snova, :P
496 * bgs100 [Jun 22 22:09:44] gives Snova humo[u]r badge
497 <bgs100> [Jun 22 22:09:54] er
498 <bgs100> [Jun 22 22:09:58] yeah
499 * bgs100 [Jun 22 22:10:07] has unilimited badge supply
500 <bgs100> [Jun 22 22:10:11] unlimited*
501 * bgs100 [Jun 22 22:10:24] gives self the keyboard failure badge
502 <seidos> [Jun 22 22:11:32] I forget things && I have a difficult time understanding things
503 <bgs100> [Jun 22 22:11:45] *shrugs*
504 <seidos> [Jun 22 22:11:47] <C3PO voice> I'm doomed </C3PO voice>
505 <pedro3005> [Jun 22 22:11:54] bgs100, I don't know how to use scanf anymore
506 <pedro3005> [Jun 22 22:11:55] :P
507 * bgs100 [Jun 22 22:11:55] teaches seidos how to fix that
508 <bgs100> [Jun 22 22:11:59] Ohwait
509 <bgs100> [Jun 22 22:12:03] That might not work
510 <bgs100> [Jun 22 22:12:12] *dad da dum*
511 <bgs100> [Jun 22 22:12:17] pedro3005, :|
512 <bgs100> [Jun 22 22:12:22] pedro3005, Seriously?
513 <pedro3005> [Jun 22 22:12:26] bgs100, not really
514 <bgs100> [Jun 22 22:12:33] Oh, good
515 <pedro3005> [Jun 22 22:12:35] to use it to get things like a name, we should use strings?
516 <seidos> [Jun 22 22:12:38] I think I still remember scanf
517 <bgs100> [Jun 22 22:12:46] Oh
518 <pedro3005> [Jun 22 22:12:54] i remember we used ints to get characters anyway
519 <seidos> [Jun 22 22:12:54] now sscanf, different story
520 <bgs100> [Jun 22 22:13:00] pedro3005, scanf isn't good for all input.
521 <bgs100> [Jun 22 22:13:05] seidos, man sscanf
522 <seidos> [Jun 22 22:13:05] server.c doesn't really make sense
523 <seidos> [Jun 22 22:13:07] ah ha!
524 <seidos> [Jun 22 22:13:10] I'm going to compile it
525 <seidos> [Jun 22 22:13:22] right-o gotta' "man up"
526 <bgs100> [Jun 22 22:13:31] xD
527 <bgs100> [Jun 22 22:13:38] Was that pun intended?
528 <seidos> [Jun 22 22:13:45] indeed
529 <bgs100> [Jun 22 22:14:34] pedro3005, e.g. the %s directive gets a string up to a whitespace. You can't easily use it to get, for instance, a line of text
530 <pedro3005> [Jun 22 22:14:37] okay, i'll use strings
531 <bgs100> [Jun 22 22:14:41] Did you look up fgets? :P
532 <pedro3005> [Jun 22 22:14:48] no :p
533 <bgs100> [Jun 22 22:14:54] Well do that :|
534 * bgs100 [Jun 22 22:15:21] ssh's into pedro3005's computer and pipes man fgets | wall
535 <pedro3005> [Jun 22 22:15:37] hey why won't this work?
536 <pedro3005> [Jun 22 22:15:40] char *name[];
537 <bgs100> [Jun 22 22:15:41] What
538 <bgs100> [Jun 22 22:15:45] ...
539 <bgs100> [Jun 22 22:16:09] pedro3005, because if you don't give it a value at declaration you can't use []
540 <pedro3005> [Jun 22 22:16:18] oh
541 <bgs100> [Jun 22 22:16:26] Also
542 <seidos> [Jun 22 22:16:31] man, I bet the error catching code in firefox is awesome
543 <bgs100> [Jun 22 22:16:34] Why do you want an array of char*'s?
544 <pedro3005> [Jun 22 22:16:43] I don't know
545 <seidos> [Jun 22 22:16:43] for the input at the URL box
546 <bgs100> [Jun 22 22:16:55] pedro3005, :|
547 <pedro3005> [Jun 22 22:17:07] :P I need to grab a name as input
548 <pedro3005> [Jun 22 22:17:18] I'll just use getchar()
549 <seidos> [Jun 22 22:17:32] why use getchar() instead of scanf()?
550 <pedro3005> [Jun 22 22:18:43] damn, I wish I still had my getchar program
551 <pedro3005> [Jun 22 22:18:53] bgs100, I forgot how to use getchar.... :p
552 <bgs100> [Jun 22 22:19:04] .......
553 <seidos> [Jun 22 22:19:06] I think I have mine somewhere
554 <bgs100> [Jun 22 22:19:10] *sigh*
555 <seidos> [Jun 22 22:19:13] I just don't know what I called it :o
556 <bgs100> [Jun 22 22:19:17] pedro3005, What exactly are you trying to do?
557 <seidos> [Jun 22 22:19:20] how do you search inside a file? grep right?
558 <pedro3005> [Jun 22 22:19:26] bgs100, challenge 2
559 <bgs100> [Jun 22 22:19:29] seidos, mhm
560 <bgs100> [Jun 22 22:20:36] pedro3005, scanf won't do well if you're trying to get a name that might have spaces... getchar() gets one individual char.
561 <bgs100> [Jun 22 22:20:47] Just call it like so: getchar()
562 <bgs100> [Jun 22 22:21:00] It will return EOF (-1) upon, well, EOF
563 <bgs100> [Jun 22 22:21:15] pedro3005, Type this into your shell:
564 <bgs100> [Jun 22 22:21:17] man fgets
565 <bgs100> [Jun 22 22:21:19] Okay?
566 <seidos> [Jun 22 22:21:27] pedro3005, I found this: while ((c = getchar()) != EOF) {
567 <seidos> [Jun 22 22:21:27] putchar(toupper(c));
568 <seidos> [Jun 22 22:21:27] if (c == '!')
569 <seidos> [Jun 22 22:21:27] printf("!!!");
570 <seidos> [Jun 22 22:21:27] }
571 <pedro3005> [Jun 22 22:21:45] yeah but then I need to store this entire name
572 <pedro3005> [Jun 22 22:21:52] getchar() gets just one char
573 <bgs100> [Jun 22 22:21:53] pedro3005, Yes...
574 <bgs100> [Jun 22 22:21:58] If you wanted
575 <bgs100> [Jun 22 22:22:07] You could build up into a char array.
576 <Snova> [Jun 22 22:22:13] getline
577 <bgs100> [Jun 22 22:22:14] And add the '\0' yourself.
578 <pedro3005> [Jun 22 22:22:49] bgs100, btw the name can't have spaces so scanf() might be good.. but I suppose it needs to detect the presence of spaces and complains
579 <pedro3005> [Jun 22 22:22:58] complain*
580 <bgs100> [Jun 22 22:23:07] Snova, Although it isn't standard :P
581 <pedro3005> [Jun 22 22:23:11] argh I just want raw_input() :(
582 <bgs100> [Jun 22 22:23:20] pedro3005, man fgets
583 <pedro3005> [Jun 22 22:23:25] I did that
584 <bgs100> [Jun 22 22:23:29] ...and?
585 <seidos> [Jun 22 22:23:46] pedro3005, are you working on the program challenges?
586 <pedro3005> [Jun 22 22:23:54] I'll try to do it with fgets() then
587 <pedro3005> [Jun 22 22:23:56] seidos, yes
588 <bgs100> [Jun 22 22:23:58] Wait
589 <bgs100> [Jun 22 22:24:04] pedro3005, The name can't have spaces?
590 <seidos> [Jun 22 22:24:05] I should do the same
591 <bgs100> [Jun 22 22:24:10] Go ahead and try scanf.
592 <bgs100> [Jun 22 22:24:20] See if it works.
593 <pedro3005> [Jun 22 22:24:35] so wait, a quick reminder.. should I do like
594 <pedro3005> [Jun 22 22:24:42] int name;
595 <bgs100> [Jun 22 22:24:49] ...
596 <bgs100> [Jun 22 22:24:51] No.
597 <pedro3005> [Jun 22 22:24:52] scanf("%d",&name);
598 <bgs100> [Jun 22 22:25:07] Unless someone's name is "57"...
599 <bgs100> [Jun 22 22:25:19] :P
600 <bgs100> [Jun 22 22:25:52] waait
601 <bgs100> [Jun 22 22:26:04] pedro3005, Where in the challenge does it say the name can't have spaces?
602 <pedro3005> [Jun 22 22:26:29] oh wait
603 <pedro3005> [Jun 22 22:26:35] it can't _begin_ with spaces
604 <pedro3005> [Jun 22 22:26:37] failure
605 <bgs100> [Jun 22 22:27:03] ....
606 <bgs100> [Jun 22 22:27:06] Indeed.
607 <pedro3005> [Jun 22 22:27:28] and I thought this was hard on Python some months ago
608 <bgs100> [Jun 22 22:28:10] pedro3005, Do something like:
609 <bgs100> [Jun 22 22:28:14] char input[21];
610 <bgs100> [Jun 22 22:28:25] fgets(input, 20, stdin);
611 <pedro3005> [Jun 22 22:28:46] bgs100, but then the input is limited :|
612 <bgs100> [Jun 22 22:28:53] And I would uggest seeing if the last non '\0' character is a newline and if so replace it with '\0'
613 <bgs100> [Jun 22 22:29:13] pedro3005, That's okay.
614 <bgs100> [Jun 22 22:29:31] "To make this simpler, I will not enter a string bigger than 20 characters for valid data, but larger strings shouldn't cause problems. Truncate them.)"
615 <seidos> [Jun 22 22:29:50] is -- an operator?
616 <bgs100> [Jun 22 22:29:57] Yes
617 <pedro3005> [Jun 22 22:29:59] don't you mean fgets(input, 21, stdin) ?
618 <bgs100> [Jun 22 22:30:02] The opposite of ++
619 <bgs100> [Jun 22 22:30:06] pedro3005, No.
620 <bgs100> [Jun 22 22:30:16] Errr
621 <bgs100> [Jun 22 22:30:18] Yes :P
622 <pedro3005> [Jun 22 22:30:20] fgets() reads in at most one less than size characters
623 <bgs100> [Jun 22 22:30:25] yeah
624 <pedro3005> [Jun 22 22:30:28] bgs100, please do man fgets
625 <pedro3005> [Jun 22 22:30:29] :P
626 * bgs100 [Jun 22 22:30:31] gives pedro3005 the correct badge
627 <bgs100> [Jun 22 22:30:37] pedro3005, Oh Har Har Har
628 * bgs100 [Jun 22 22:30:50] whacks pedro3005 with meterstick
629 <bgs100> [Jun 22 22:31:01] er
630 * bgs100 [Jun 22 22:31:05] notices time
631 <bgs100> [Jun 22 22:31:09] CLASS DISMISSED
632 <pedro3005> [Jun 22 22:31:10] bgs100, but wouldn't there be a way not to limit the input?
633 <bgs100> [Jun 22 22:31:15] pedro3005, Yes
634 <bgs100> [Jun 22 22:31:17] In fact
635 <bgs100> [Jun 22 22:31:28] pedro3005, I was annoyed by exactly the same thing before.
636 <bgs100> [Jun 22 22:31:38] How hard it was to get not-so-limited input
637 <bgs100> [Jun 22 22:31:47] I ended up just writing a function :P
638 <pedro3005> [Jun 22 22:32:38] int fuck_scanf() {
639 <pedro3005> [Jun 22 22:33:00] because that's what I feel like
640 <bgs100> [Jun 22 22:33:08] ...
641 <bgs100> [Jun 22 22:33:26] I wrote this a while back, it may not be totally correct (pings Snova), but:
642 <pedro3005> [Jun 22 22:34:07] hey I could actually use goto in this
643 <bgs100> [Jun 22 22:34:50] http://paste.pocoo.org/show/228775/
644 <pedro3005> [Jun 22 22:35:48] ugh
645 <Snova> [Jun 22 22:36:01] eh?
646 <bgs100> [Jun 22 22:36:04] getline() should be used similarly to raw_input() (without optional text to print)
647 <bgs100> [Jun 22 22:36:24] Snova, Mind checking code I wrote a long time ago? :P
648 <bgs100> [Jun 22 22:36:35] brb
649 <Snova> [Jun 22 22:38:37] interesting
650 <Snova> [Jun 22 22:39:23] it's fairly dense, but seems to work right
651 <bgs100> [Jun 22 22:39:32] yaaay
652 <Snova> [Jun 22 22:39:34] barring tricksy little off-by-one errors
653 <pedro3005> [Jun 22 22:43:11] gah
654 <pedro3005> [Jun 22 22:43:16] } while ((isspace(char[0])) || !(char[0]));
655 <bgs100> [Jun 22 22:43:16] pedro3005, ?
656 <bgs100> [Jun 22 22:43:19] er
657 <pedro3005> [Jun 22 22:43:19] why doesn
658 <bgs100> [Jun 22 22:43:25] I mean
659 <pedro3005> [Jun 22 22:43:25] it work
660 <bgs100> [Jun 22 22:43:32] I'll be taking questions next class :P
661 <pedro3005> [Jun 22 22:43:42] Snova? :p
662 <bgs100> [Jun 22 22:43:50] Uh
663 <bgs100> [Jun 22 22:43:54] I was kidding :|
664 <pedro3005> [Jun 22 22:44:02] oh
665 <bgs100> [Jun 22 22:44:07] *sighs*
666 <bgs100> [Jun 22 22:44:25] pedro3005, What is that } about?
667 <pedro3005> [Jun 22 22:44:29] do while
668 <bgs100> [Jun 22 22:44:44] Could I see the do? :P
669 <pedro3005> [Jun 22 22:45:22] do {
670 <pedro3005> [Jun 22 22:45:22] puts("Enter your forum name.");
671 <pedro3005> [Jun 22 22:45:22] fgets(input, 21, stdin);
672 <pedro3005> [Jun 22 22:45:22] }
673 <bgs100> [Jun 22 22:45:32] ...
674 <bgs100> [Jun 22 22:45:34] what is char?
675 <pedro3005> [Jun 22 22:45:49] hm?
676 <bgs100> [Jun 22 22:46:04] You take it into input, then use "char"
677 <bgs100> [Jun 22 22:46:12] ...
678 <pedro3005> [Jun 22 22:46:50] bgs100, oh failure
679 <pedro3005> [Jun 22 22:46:53] my god
680 <pedro3005> [Jun 22 22:46:56] how did I..
681 <bgs100> [Jun 22 22:46:58] *facepalm*
682 <seidos> [Jun 22 22:47:08] is there a way to put a text file into the paste buffer via the command line?
683 <seidos> [Jun 22 22:47:16] like sample.txt > paste
684 <seidos> [Jun 22 22:47:18] or something?
685 <bgs100> [Jun 22 22:47:20] Paste buffer?
686 <seidos> [Jun 22 22:47:29] copy buffer?
687 <seidos> [Jun 22 22:47:34] frame buffer?
688 <bgs100> [Jun 22 22:47:38] ...
689 <pedro3005> [Jun 22 22:47:39] bgs100, it works bitches!!!
690 <pedro3005> [Jun 22 22:47:41] :P
691 <seidos> [Jun 22 22:47:45] I'm not sure what it's called
692 * bgs100 [Jun 22 22:47:48] slaps pedro3005
693 <bgs100> [Jun 22 22:48:07] pedro3005, Also, I am not plural :P
694 <seidos> [Jun 22 22:48:17] why doesn't this loop go negative for(i=99; i>=0; i--)?
695 <bgs100> [Jun 22 22:48:18] I AM THE COLLECTIVE
696 <pedro3005> [Jun 22 22:48:26] I was referring to the bitches in general
697 <bgs100> [Jun 22 22:48:31] oh
698 <bgs100> [Jun 22 22:48:36] I AM THE COLLECTIVE!
699 <bgs100> [Jun 22 22:48:38] :P
700 <bgs100> [Jun 22 22:48:51] seidos, Errr
701 <pedro3005> [Jun 22 22:48:54] bgs100, I excluded you out of niceness, be grateful
702 <bgs100> [Jun 22 22:48:59] Are you sure it isn't?
703 <bgs100> [Jun 22 22:49:11] pedro3005, *rolls eyes*
704 <pedro3005> [Jun 22 22:49:42] bgs100, you'll have to explain your code next class :p
705 <bgs100> [Jun 22 22:49:49] :|
706 <bgs100> [Jun 22 22:49:53] ...okay :P
707 * bgs100 [Jun 22 22:50:07] goes off to do other computer stuff
708 <seidos> [Jun 22 22:50:30] pedro3005, can you see why my loop doesn't go negative so it will stop?
709 <seidos> [Jun 22 22:50:45] if I set it >=1 it stops, but >=0 it just loops forever
710 <pedro3005> [Jun 22 22:51:04] hmmm
711 <pedro3005> [Jun 22 22:52:57] here it works
712 <pedro3005> [Jun 22 22:53:07] int main() {
713 <pedro3005> [Jun 22 22:53:07] int i;
714 <pedro3005> [Jun 22 22:53:08] for (i=10; i >= 0; i--)
715 <pedro3005> [Jun 22 22:53:08] puts("Hello.");
716 <pedro3005> [Jun 22 22:53:08] return 0;
717 <pedro3005> [Jun 22 22:53:08] }
718 <pedro3005> [Jun 22 22:53:25] it prints 10 times
719 <pedro3005> [Jun 22 22:53:33] no more
720 <pedro3005> [Jun 22 22:53:35] no less
721 <pedro3005> [Jun 22 22:53:38] :p
722 <bgs100> [Jun 22 22:54:47] hmm
723 <bgs100> [Jun 22 22:54:54] seidos, is i a normal int?
724 <seidos> [Jun 22 22:54:59] yeah
725 <seidos> [Jun 22 22:55:01] int i;
726 <bgs100> [Jun 22 22:55:04] hmm
727 <seidos> [Jun 22 22:55:06] long int?
728 <bgs100> [Jun 22 22:55:10] what are you doing in the loop?
729 <seidos> [Jun 22 22:55:53] printf's
730 <bgs100> [Jun 22 22:56:10] Paste?
731 <seidos> [Jun 22 22:56:44] http://paste.ubuntu.com/453703/
732 <pedro3005> [Jun 22 22:56:54] seidos, ##philosophy gets quite... interesting
733 <pedro3005> [Jun 22 22:56:56] to say the least
734 <seidos> [Jun 22 22:57:06] someone pm'ed earlier
735 <seidos> [Jun 22 22:57:19] was trying to say that suffering is what humans crave
736 <seidos> [Jun 22 22:57:30] because it gives them/us "individuality"
737 <bgs100> [Jun 22 22:57:37] :|
738 <seidos> [Jun 22 22:57:37] he said happiness was overrated
739 <bgs100> [Jun 22 22:57:43] Uhhh
740 <bgs100> [Jun 22 22:57:45] seidos,
741 <seidos> [Jun 22 22:57:46] I said individuality is overrated
742 * seidos [Jun 22 22:57:51] hides
743 <pedro3005> [Jun 22 22:57:55] well that's okay
744 <bgs100> [Jun 22 22:58:01] I think you want == in those if's
745 <bgs100> [Jun 22 22:58:06] not ='s
746 <bgs100> [Jun 22 22:58:10] Those assign i...
747 <pedro3005> [Jun 22 22:58:10] <Kjixill> i need to cut down on my masturbation habits
748 <pedro3005> [Jun 22 22:58:14] however..
749 <pedro3005> [Jun 22 22:58:15] :P
750 <bgs100> [Jun 22 22:58:21] Not check if it is a value..
751 <seidos> [Jun 22 22:58:31] yes. that was an epic fail.
752 <seidos> [Jun 22 22:58:49] thank you
753 <seidos> [Jun 22 22:58:53] I do that to damn much
754 <seidos> [Jun 22 22:59:00] s/to/too
755 <bgs100> [Jun 22 22:59:07] :p
756 <seidos> [Jun 22 22:59:51] no wonder I got a warning from the compiler :/
757 <seidos> [Jun 22 23:00:03] man
758 <seidos> [Jun 22 23:00:25] hindsight is miraculous
759 <bgs100> [Jun 22 23:00:28] seidos, Pay attention to those
760 <bgs100> [Jun 22 23:00:51] When you have a problem, paste the warnings (if there's only a few on IRC)
761 <seidos> [Jun 22 23:00:55] I'll do my best
762 <bgs100> [Jun 22 23:01:55] :)
763 <seidos> [Jun 22 23:12:00] I don't get how can I take chars using scanf
764 <seidos> [Jun 22 23:12:10] "%d" is for ints
765 <seidos> [Jun 22 23:12:18] but I don't know what to use for chars
766 <seidos> [Jun 22 23:12:25] man scanf doesn't seem to say
767 <pedro3005> [Jun 22 23:12:39] %c?
768 <seidos> [Jun 22 23:13:27] I don't know, I still get some warnings
769 <pedro3005> [Jun 22 23:13:40] me neither
770 <seidos> [Jun 22 23:13:50] but I think that fixed some of them maybe
771 <seidos> [Jun 22 23:16:18] I like this warning "comparison with string literal results in unspecified behavior
772 <seidos> [Jun 22 23:16:19] "
773 <seidos> [Jun 22 23:16:26] I mean, what is "unspecified behavior"?
774 <seidos> [Jun 22 23:16:29] let's find out!
775 * seidos [Jun 22 23:16:33] executes binary
776 <seidos> [Jun 22 23:17:01] it wouldn't execute :(
777 <seidos> [Jun 22 23:18:07] compiling to a text file using > doesn't work to grab the warnings into a file
778 <seidos> [Jun 22 23:18:40] ah, wasn't seeing an error
779 * seidos [Jun 22 23:18:56] facepalms himself *thwap*
780 <seidos> [Jun 22 23:19:07] stdio.c? no! stdio.h
781 * seidos [Jun 22 23:19:19] bangs his head and chants "stupid, stupid, stupid"
782 <bgs100> [Jun 23 00:51:52] Night
learners/22062010 (last edited 2010-06-26 04:59:32 by 117)