19062010

   1  <bgs100>       ==================== C CLASS BEGIN! ====================
   2  <bgs100>       Alright
   3  <pedro3005>    bgs100, what about my pointer questions? :p
   4  <bgs100>       We have actually been using the file-related library th-
   5  <bgs100>       >:|
   6  <bgs100>       I answered those
   7  <pedro3005>    ok go on
   8  <bgs100>       We will review homework at the end of class...
   9  <bgs100>       this time
  10  <bgs100>       We have actually been using the file-related library this whole time
  11  <bgs100>       stdio.h
  12  <juju2143>     k
  13  <bgs100>       It stands for: Standard Input/Output
  14  <bgs100>       Now
  15  <bgs100>       When we call printf, puts, scanf, or whatever, we are actually writing/reading from files
  16  <pedro3005>    :OOO
  17  <juju2143>     :o
  18  <juju2143>     stdin/stdout?
  19  <bgs100>       (In Unix, anyway) stout (output), stdin (input), and stderr (We haven't used this; it's for errors) are all actually files
  20  <bgs100>       juju2143, Correct!
  21  <pedro3005>    I'm not actually surprised, I just thought you were going for that effect so I helped ya
  22  *      bgs100 gives juju2143 one of pedro3005's old stars
  23  <juju2143>     yay
  24  <bgs100>       pedro3005, lol
  25  *      bgs100 shines up the star
  26  <bgs100>       So yeah
  27  <bgs100>       Now
  28  <pedro3005>    bgs100, cool, makes a lot of sense
  29  <bgs100>       Good,
  30  <pedro3005>    wait
  31  <pedro3005>    what if I do this...
  32  <bgs100>       In C, there are actually two (main) ways to repre-
  33  <bgs100>       wat
  34  <pedro3005>    pedro@pedro:~$ echo "a" > stdout
  35  <bgs100>       uh
  36  <bgs100>       You made a file
  37  <bgs100>       congrats :P
  38  <bgs100>       pedro3005, Try this:
  39  <juju2143>     lol
  40  <bgs100>       pedro3005, echo "pie" > /dev/stdout
  41  <juju2143>     you may want to do > /dev/stdout
  42  *      bgs100 juju2143 another star
  43  <juju2143>     yay<
  44  *      juju2143 pins it with te other
  45  <bgs100>       alright
  46  <bgs100>       so
  47  <bgs100>       yeah
  48  <pedro3005>    I thought about /dev :( but I thought it'd result in permission error
  49  <bgs100>       pedro3005, lol, nope
  50  <pedro3005>    bgs100, ok go on
  51  <bgs100>       Otherwise it could be difficult to call printf() ;D
  52  <bgs100>       alright
  53  <juju2143>     kay.
  54  <bgs100>       okay
  55  <bgs100>       so yeah
  56  <bgs100>       Now
  57  <bgs100>       In C, there are actually two (main) ways to represent a file,
  58  <juju2143>     now.,
  59  *      bgs100 retracts star from juju2143 
  60  <seidos>       what does echo "pie" > /dev/stdout do?
  61  <bgs100>       seidos, Did you try it?
  62  <seidos>       I check to see if it put anything in /dev/stdout but my vim is blank
  63  <seidos>       bgs100, yeah
  64  <bgs100>       Did it print out "pie"?
  65  *      seidos nods
  66  <bgs100>       Okay
  67  <bgs100>       seidos, /dev/stdout is a special file, representing standard output.
  68  <juju2143>     stdout is a peripherial represented as a file
  69  *      bgs100 gives juju2143 star back
  70  <bgs100>       OKAY
  71  <bgs100>       In C, there are actually two (main) ways to represent a file,
  72  <juju2143>     What they are?
  73  <bgs100>       By integer (file descriptor),
  74  <seidos>       why isn't there anything in the file?
  75  <bgs100>       and by a special structure
  76  <bgs100>       seidos, It's special, okay? :p
  77  <seidos>       bgs100, all right, all right
  78  <bgs100>       Actually
  79  <bgs100>       seidos, Look at the bottom of vim
  80  <bgs100>       Here, it says: ""/dev/stdout" is not a file"
  81  <seidos>       oooohhhhhh
  82  <bgs100>       thar ya go
  83  <seidos>       that's weird
  84  <bgs100>       So yeah
  85  <seidos>       sending Pie to it, but it's not a file
  86  <bgs100>       Everything is a file
  87  <bgs100>       Vim acknowledges that this one is different :P
  88  <bgs100>       moving on.
  89  <bgs100>       For the beginning of today, we will be dealing with function that have to do with the special structure.
  90  <seidos>       it's like the blackhole file :D
  91  <bgs100>       No
  92  <bgs100>       That is /dev/null
  93  <seidos>       :(
  94  <bgs100>       :p
  95  <juju2143>     lol.
  96  <seidos>       they are both "not files" according to vim
  97  <bgs100>       MOVING ON
  98  <seidos>       all right, moving on, sorry
  99  <bgs100>       np lol
 100  *      bgs100 was kidding :p
 101  <pedro3005>    MOVING ON
 102  <bgs100>       Alright, I'm oging to make an example
 103  <bgs100>       pedro3005, ...
 104  <bgs100>       going*
 105  <seidos>       hey bgs100, what is the most complex program, in C, that you have...understood?  worked on?  I dunno
 106  <pedro3005>    Oging
 107  <pedro3005>    The act of poking, jabbing or prodding someone with a blunt, hard object.
 108  *      bgs100 retracts pedro3005's star
 109  <bgs100>       seidos, hmm
 110  <seidos>       pedro3005, that's an actual word?
 111  <pedro3005>    seidos, nah, urban dictionary
 112  <seidos>       yes!  I made the teacher think
 113  <pedro3005>    :P
 114  <seidos>       oh.
 115  <seidos>       I think ogling is a word.  yeah spell checker has it
 116  <bgs100>       Alright
 117  <seidos>       bgs100, do I already know the answer?  your bot?
 118  <bgs100>       ...
 119  <bgs100>       My bot is written in Python :p
 120  <seidos>       oh
 121  <juju2143>     lol.
 122  <bgs100>       Okay, pastebining
 123  <bgs100>       http://pastebin.com/LeKHSz6Q
 124  <bgs100>       SCRO , and then run "cat lucky.txt"
 125  <pedro3005>    bgs100, easier than I expected
 126  <juju2143>     julien@maelstrom:~/ctests$ gcc file.c -o file
 127  <seidos>       bgs100, filename?
 128  <juju2143>     file.c:1:9: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
 129  <seidos>       bgs100, lucky?
 130  <bgs100>       juju2143, lolwut
 131  <bgs100>       juju2143, I didn't have "<" anywhere in there
 132  <bgs100>       seidos, 11.c ? :P
 133  <seidos>       juju2143, did you use the -Wall option with gcc?
 134  <juju2143>     oh right
 135  <juju2143>     I forgot the # in #include
 136  *      seidos has no idea what -Wall does but he's been using it
 137  <bgs100>       juju2143, .... xP
 138  <seidos>       bgs100, I want to be able to reference it later
 139  <juju2143>     julien@maelstrom:~/ctests$ ./file
 140  <juju2143>     What is your lucky number? OVER 9000
 141  <juju2143>     julien@maelstrom:~/ctests$ cat lucky.txt
 142  <juju2143>     Your lucky number is 134513963, just in case you forgot.
 143  <juju2143>     julien@maelstrom:~/ctests$
 144  <seidos>       cat: lucky.txt: No such file or directory
 145  <seidos>       oh crap, didn't run the program
 146  <juju2143>     loool.
 147  <seidos>       *facepalm*
 148  <bgs100>       juju2143, ...
 149  <seidos>       cool, my lucky number is 76, just in case I forgot
 150  <juju2143>     lol.
 151  <bgs100>       juju2143, a specific number, please :p
 152  <juju2143>     ok
 153  <juju2143>     julien@maelstrom:~/ctests$ ./file
 154  <juju2143>     What is your lucky number? 42
 155  <juju2143>     julien@maelstrom:~/ctests$ cat lucky.txt
 156  <juju2143>     Your lucky number is 42, just in case you forgot.
 157  <seidos>       42 vs 76 who wins?
 158  <bgs100>       42 :p
 159  <bgs100>       That's what I picked :P
 160  <seidos>       I wonder if a grand poo bah of a masonic order would agree
 161  <juju2143>     lol :P
 162  <seidos>       :P
 163  <bgs100>       1337 pwns both
 164  <seidos>       haha
 165  <juju2143>     julien@maelstrom:~/ctests$ cat lucky.txt
 166  <juju2143>     Your lucky number is 31137, just in case you forgot.
 167  <juju2143>     pwned
 168  <bgs100>       naaah
 169  <bgs100>       I'm the teacher, I say not :P
 170  <juju2143>     k then.
 171  <pedro3005>    bgs100, moving on :p
 172  <seidos>       Your lucky number is -1208653712, just in case you forgot.
 173  <seidos>       that is the number for "Pi"
 174  <bgs100>       ...
 175  <seidos>       my computer must be broken
 176  <bgs100>       seidos, "Pi" is not a number
 177  <bgs100>       pi is a number.
 178  <pedro3005>    if you import math?
 179  <seidos>       bgs100, sure it is, it's an irrational transcendental number
 180  <bgs100>       "Pi" is a string
 181  <seidos>       oh lowercase "P"?
 182  <bgs100>       No
 183  <bgs100>       "pi" is a string too
 184  <bgs100>       Neither are number
 185  <pedro3005>    bgs100, there should be a C interpreter
 186  <bgs100>       There is
 187  <pedro3005>    compiling is so *ugh*
 188  <bgs100>       pedro3005, lol
 189  <pedro3005>    bgs100, where?
 190  <seidos>       pedro3005, that's probably sacrilegious
 191  <pedro3005>    I'm like "Ohh, I should try this out. But then I'd have to compile.... oh... *gives up*"
 192  <bgs100>       pedro3005, The google power is obviously not with you.
 193  <bgs100>       http://www.google.com/search?client=ubuntu&channel=fs&q=C+Interpreter&ie=utf-8&oe=utf-8
 194  <juju2143>     g2g bai.
 195  <bgs100>       bai
 196  <seidos>       later
 197  <bgs100>       Okay
 198  <bgs100>       So yeah
 199  <bgs100>       Moving away from pi
 200  <bgs100>       So
 201  <bgs100>       Let's look at this.
 202  <bgs100>       Let's take a step back, and see it as pseudo code
 203  <bgs100>       Include input/output library
 204  <bgs100>       Define main:
 205  <bgs100>       <declaring stuff>
 206  <bgs100>       Print "What is your lucky number? "
 207  <bgs100>       Scan a number from input into the variable 'num'
 208  <bgs100>       Open the file "lucky.txt" for writing (that's what the "w" means)
 209  <seidos>       *file is a pointer?
 210  <bgs100>       Yeap
 211  <bgs100>       That's what file functions use and return
 212  <bgs100>       One sec
 213  <bgs100>       Print "Your lucky number is <num>, in case you forgot." into file
 214  <bgs100>       Close file.
 215  <bgs100>       The end.
 216  <bgs100>       So yeah
 217  <bgs100>       We already know about printf/scanf,
 218  <seidos>       fprintf is obviously different
 219  <bgs100>       fopen opens in a file in a mode (run "man fopen")
 220  <bgs100>       seidos, Yes
 221  <seidos>       it makes sense, generally
 222  <bgs100>       It is veyr similar though
 223  <bgs100>       very*
 224  <pedro3005>    bgs100, do you use Geany?
 225  <bgs100>       printf is basically fprintf with the first argument as "stdout"
 226  <bgs100>       pedro3005, Not too often
 227  <bgs100>       sometimes
 228  <bgs100>       Much lighter than most IDEs
 229  <bgs100>       Anyway
 230  <bgs100>       fprintf is just like printf, but it outputs to a file of your choice
 231  <bgs100>       In this case, file.
 232  <bgs100>       fclose closes a file, writing any changes that may not have actually taken place yet as well.
 233  <seidos>       pointers trip me out, I know that file is related to *file, but not quite sure how
 234  <bgs100>       uhhhh
 235  <bgs100>       file is a variable
 236  <bgs100>       it is a FIle *
 237  <bgs100>       FILE *
 238  <bgs100>       That is why there is a * in front of "file" when why declare it
 239  <bgs100>       Okay?
 240  <seidos>       you declare *file, a pointer, and then you can use file the variable?
 241  <bgs100>       *file is not the pointer
 242  <bgs100>       There is no *file
 243  <seidos>       I asked earlier if it was, and you said it was
 244  <bgs100>       ?
 245  <bgs100>       Asked what?
 246  <bgs100>       No
 247  <pedro3005>    <seidos> *file is a pointer?
 248  <pedro3005>    <bgs100> Yeap
 249  <bgs100>       *sigh*
 250  <bgs100>       Okay
 251  <seidos>       pedro3005, was faster than me
 252  <bgs100>       Look
 253  <seidos>       bgs100, maybe the yeap wasn't for me
 254  <bgs100>       seidos, Here
 255  <bgs100>       Look
 256  <seidos>       bgs100, I'll use the google pwr to search on pointers?
 257  <bgs100>       seidos,
 258  <bgs100>       No
 259  <bgs100>       Listen (or rather watch)
 260  <bgs100>       Take the line that says:
 261  <pedro3005>    bgs100, http://i.imgur.com/bS8rd.png
 262  <bgs100>           FILE *file;
 263  <bgs100>       pedro3005, green bar?
 264  <bgs100>       seidos,
 265  <bgs100>       Replace:
 266  <bgs100>           FILE *file;
 267  <bgs100>       with:
 268  <pedro3005>    bgs100, don't you see it?
 269  <bgs100>           FILE* file;
 270  <bgs100>       oh
 271  <bgs100>       yeah
 272  <bgs100>       pedro3005, I don't know
 273  <pedro3005>    :(
 274  <bgs100>       seidos, Okay?
 275  <seidos>       yeah, see it
 276  <bgs100>       Did you replace?
 277  <seidos>       roger
 278  <bgs100>       Good
 279  <bgs100>       This is exactly the same thing
 280  <seidos>       working on it
 281  <bgs100>       Now, look at that
 282  <bgs100>       You are declaring file as a FILE*
 283  <bgs100>       Alright?
 284  <seidos>       dude, that's weird
 285  <bgs100>       I just prefer to put the * next to the variable.
 286  <seidos>       you can put the * either place
 287  <bgs100>       *more sigh*
 288  <bgs100>       seidos, Yes
 289  <bgs100>       That is correct
 290  <seidos>       come on!  you gotta' admit that's weird
 291  <bgs100>       C doesn't complain about whitespace that much
 292  <pedro3005>    so what is FILE?
 293  <bgs100>       FILE
 294  <bgs100>       is a struct
 295  <pedro3005>    why does it have a *?
 296  <seidos>       FILE is a struct
 297  <bgs100>       pedro3005,
 298  <seidos>       and FILE* is a struct?
 299  <bgs100>       No.
 300  <bgs100>       FILE* is a pointer to a struct
 301  <bgs100>       ...
 302  <bgs100>       pedro3005, Okay, it has a * because we want it to be a pointer,
 303  <bgs100>       and why do we want that?
 304  <seidos>       so what's the pointer?  the *?
 305  <bgs100>       Because fopen, fprintf, fclose, and all their friends all use FILE*
 306  <seidos>       FILE is a struct
 307  <seidos>       file is var
 308  <bgs100>       argh :p
 309  <bgs100>       seidos, * makes it a pointer to a FILE struct instead of a FILE struct.
 310  <bgs100>       Okay?
 311  <seidos>       it doesn't make intuitive sense, but okay
 312  <bgs100>       NOW
 313  *      seidos shrugs
 314  <bgs100>       Why do fprintf, fclose, fopen etc use FILE*'s?
 315  <seidos>       hmmm
 316  <bgs100>       This is an educated guess, but probably because that way the can modify the actual FILE struct.
 317  <pedro3005>    bgs100, which file struct?
 318  <bgs100>       .......
 319  <bgs100>       The one that fopen gave you a pointer to
 320  <bgs100>       seidos, FILE* is different than FILE. We make a variable, file, that is a FILE*, and NOT a FILE
 321  <pedro3005>    bgs100, but I don't understand how can you assign something as a pointer before pointing it to anything
 322  <bgs100>       Uh
 323  <seidos>       bgs100, I'm still tripping.  we made a *file that was a FILE a few minutes ago, now we're make a file that is a FILE*, but they are the same
 324  <bgs100>       You are assigning it so it can be pointing to something
 325  <bgs100>       pedro3005, ^
 326  <pedro3005>    bgs100, ok
 327  <bgs100>       seidos, Forget the previous thing
 328  <seidos>       bgs100,  what is pointing to what?
 329  <bgs100>       file is pointing to a FILE
 330  <bgs100>       okay?
 331  <seidos>       so file is a pointer
 332  <bgs100>       Yes!!!
 333  <seidos>       I thought you said it was a variable
 334  <seidos>       is variable = pointer?
 335  <bgs100>       IT IS!!!!!!!!!
 336  <bgs100>       seidos,
 337  <bgs100>       int a = 5;
 338  <bgs100>       Okay
 339  <seidos>       a is a variable
 340  <bgs100>       See that line.
 341  <bgs100>       Stare at it
 342  <bgs100>       seidos, And...
 343  *      seidos stares with all his might
 344  <bgs100>       a is also an integer!
 345  <seidos>       pointer is a data type!
 346  <bgs100>       That doesn't mean that 5 by itself is a variable, though!
 347  <pedro3005>    brb
 348  <bgs100>       seidos, YES!!!
 349  <bgs100>       Yay
 350  <seidos>       man, that was sick
 351  <bgs100>       what do you mean? :p
 352  <seidos>       too much work for me to see that it was a data-type
 353  <seidos>       :|
 354  <bgs100>       lol
 355  <bgs100>       took me like a friggin' week to get it
 356  <seidos>       okay, gotta' remember that, pointer is a datatype
 357  <bgs100>       seidos, lol, yeah, I wrote it down in a text file
 358  <seidos>       I'm still don't think I fully grasp it, but that makes more sense
 359  <bgs100>       after having it snap
 360  <seidos>       *I
 361  <bgs100>       infact
 362  <Snova>        oh hai
 363  <bgs100>       I might have my old notes on C
 364  <seidos>       maybe I should bring my notepad
 365  <bgs100>       That were taken while I was learning
 366  *      seidos waves @ Snova
 367  <bgs100>       Hai Snova
 368  <seidos>       dude, can you paste them?
 369  <bgs100>       Snova, I think someone just achieved pointer enlightenment
 370  *      seidos shakes his head
 371  <seidos>       I don't think I'm "pointer enlightened" yet
 372  <juju2143>     ohai
 373  <bgs100>       I hope so; I don't want to have to answer too many more pointer questions xP
 374  *      seidos waves @ juju2143 
 375  <juju2143>     :P
 376  <seidos>       sorry bro, it's like now that I know it's a datatype, I don't really know what kind it is
 377  <seidos>       it's not as intuitive as int, you know?
 378  <seidos>       at least I remember you saying that it allows actual modification of the struct
 379  <bgs100>       alright
 380  <bgs100>       seidos, You can think of a pointer as a special datatype that modifes another
 381  <bgs100>       pasting old notes
 382  <bgs100>       which were actually really short
 383  <seidos>       hmmm that makes sense I think
 384  <seidos>       more "special" things
 385  <bgs100>       Snova, You wanna explain for a minute? :P
 386  <seidos>       first files, now datatypes
 387  <Snova>        seidos: C has exactly one kind of data, and that is "bytes". everything else exists as programmer convenience :p
 388  <pedro3005>    back
 389  <Snova>        when you type "int x;" you get four bytes in a row to be used as an integer. operations such as +*-/ on it will trigger the appropriate processor instructions to actually use it as an integer
 390  <Snova>        if you type "int* x;" you still get four bytes in a row, but it's not meant to be used as a normal number, but a memory address containing the address of some other integer
 391  <bgs100>       seidos, http://pastebin.com/wMiU0eNJ
 392  <bgs100>       It's highlighted like bash because I couldn't find the plain text :p
 393  <seidos>       bgs100, ascii art?
 394  <bgs100>       Lol, yeah
 395  <seidos>       Snova, I'm kind of sorry I asked.  this "c rabbit hole" probably goes down further than I would like, doesn't it?
 396  <Snova>        seidos: the hole is pretty shallow, actually, once you hit "memory"
 397  <seidos>       I mean all data types are bytes?  that just makes me want to ask more questions
 398  <bgs100>       Snova, methinks you've crated more work :p
 399  <Snova>        on some level. the difference between "float" and "int" is 1) the number of bytes they take up, and 2) the instructions the compiler will generate on them
 400  <bgs100>       created*
 401  <seidos>       Snova,  so as soon as we get to "processor instruction" that is the explanation for why there are different types of data to the programmer?
 402  <bgs100>       seidos, So you don't have to remember the number of bytes yourself.
 403  <Snova>        seidos: the x86 architecture has a set of integer instructions, and a set of floating-point instructions, but there is nothing to prevent you from applying one to the other (other than common sense)
 404  <seidos>       bytes seem so abstracted from int and float to me, I'm not sure how that helps me at this point
 405  <Snova>        probably not; ignore that then
 406  <bgs100>       Lol
 407  *      bgs100 brings out Men in Black memory-erasing pen
 408  *      bgs100 erases seidos's memory of the last few lines and makes seidos type in /clear
 409  <Snova>        every "int" you create takes up memory somewhere. an "int*" is simply another int that "happens" to contain the memory address of another int
 410  <seidos>       no, I think it'll be useful I just have to mull it over, or work with it so that it settles into my consciousness
 411  <seidos>       as long as my brain doesn't vomit it up, which it likes to do far too often
 412  *      bgs100 gives seidos some psychological pepto-bismol
 413  <Snova>        hehe
 414  *      seidos prays
 415  <seidos>       it's a psychological placebo
 416  <Snova>        seidos: are you reasonably familiar with the concept of a function? even just the idea; has bgs demonstated them yet?
 417  <bgs100>       I have somewhat.
 418  <seidos>       Snova, depends what you mean by "reasonable"
 419  <Snova>        good enough
 420  <bgs100>       Only one example so far have we actually made a function, though
 421  <Snova>        seidos: when you pass an "int" to a function, what that function gets is a copy. if it changes it, it only changes the copy. this is not always desirable, and why we have pointers
 422  <seidos>       I don't know to be honest.  I don't want to say that I have a good enough understanding when I don't
 423  <seidos>       hmmm, that's interesting
 424  <Snova>        seidos: if that function instead took an "int pointer", rather than having a copy of an integer, it would know where it was instead- and have the ability to modify the real thing
 425  <seidos>       so a pointer is a data type that allows a function to modify the data in the memory address directly
 426  <Snova>        sure
 427  <seidos>       but an int will modify a copy of it
 428  <bgs100>       Well, thats what it's often used for
 429  <Snova>        (note that, if you pass it an "int pointer", you're actually giving it a copy of said pointer- you can have pointers to pointers and so on but this is uncommon)
 430  <bgs100>       Snova, **argv :p
 431  <Snova>        bgs100: that's more of a pointer array
 432  <bgs100>       eh
 433  <Snova>        well, same thing really
 434  <bgs100>       multi-dimensional arrays in general.
 435  <bgs100>       Snova, yeah
 436  <bgs100>       So
 437  <Snova>        well... no, a multi-dimensional array has to be rectangular
 438  <bgs100>       ?
 439  <bgs100>       Isn't it an array of arrays?
 440  <Snova>        yes, but they do have to be the same size for it to work
 441  <bgs100>       Oh.
 442  <bgs100>       meh
 443  <bgs100>       Anyway
 444  <Snova>        :p
 445  *      bgs100 prepares next example.
 446  <Snova>        99% of the time what pointers are actually used for is to modify someone elses variables, so describing them from that viewpoint is probably logical
 447  <bgs100>       Yeah
 448  <Snova>        oh, and dynamic allocation, but rather than asking malloc to modify something you're asking it to create it for you... I suppose it's the other way around; malloc is returning something for /you/ to modify
 449  <seidos>       Snova, what's the most complex c project you've worked on?
 450  <seidos>       I realize there is a hierarchy to code, I'm just not sure of the layers
 451  <Snova>        dunno, I don't use C much
 452  <seidos>       like how high up is Firefox?  I imagine it's at the top.  Or gnome-power-manager
 453  <seidos>       Snova, python mostly?
 454  <bgs100>       seidos, Gnome itself is written in C, if I recall correctly.
 455  <Snova>        in terms of complexity? firefox would be up there, certainly; something like gnome-power-manager I don't know... it has a fairly straightforward purpose, I guess, but it does a lot of things
 456  <Snova>        seems to mostly be a configuration tool
 457  <seidos>       bgs100, it looks like GNU/Linux is so hacked together it's hard to tell where one project begins and another ends for me
 458  <Snova>        it is :p
 459  <bgs100>       lol
 460  <seidos>       like I don't really know where gnome ends and x begins, or I should probably say where X ends and gnome begins
 461  <seidos>       I have a faint idea, but I don't really know in detail
 462  <seidos>       I do remember pausing some processes awhile back just to see what would happen though
 463  <Snova>        mmm, X is a complicated beast
 464  <bgs100>       seidos, I like to think of it as a complex hierarchy. Perhaps combined with GTK+, or maybe above it, and sitting on top of X, GNOME is also associated with many 'gnome" projects.
 465  <seidos>       that's true, like gnometris
 466  <bgs100>       Like KDE is assocated with everytihng that starts with a K or has a capital K in it.
 467  <seidos>       heh
 468  <bgs100>       :P
 469  <seidos>       that's a good point, I remember trying to program my blackjack game in python
 470  <bgs100>       seidos, pedro3005
 471  <bgs100>       http://paste.pocoo.org/show/227450/
 472  <seidos>       then saw the blackjack that came with gnome
 473  <bgs100>       Now,
 474  <bgs100>       save and compile, but DO NOT RUN
 475  <seidos>       and was just like blown away how little I knew
 476  <bgs100>       pedro3005, That means DO NOT RUN
 477  <seidos>       it was actually quite depressing
 478  <Snova>        X touches a lot of different parts of the system; its roots go deep into the kernel... but X stops when things are being displayed on the screen properly, and Gnome picks up there to draw basically everything
 479  <bgs100>       seidos, pshaw, the guys who made that blackjack game were once new too.
 480  <Snova>        20:21:01 <bgs100> Now,
 481  <Snova>        oops
 482  <seidos>       but firefox doesn't need gnome to function does it?
 483  <bgs100>       Snova, lolwut
 484  <bgs100>       seidos, No, just gtk
 485  <seidos>       ah gtk as a dependency
 486  <seidos>       so you have to have gtk libraries installed
 487  <Snova>        seidos: nope. it uses certain gnome components (e.g. gtk) but gtk talks directly to X. also, things like gnome's window manager are technically separate components but rather imporatnt
 488  <seidos>       I don't really get that
 489  <bgs100>       seidos, Did you save and compile?
 490  <seidos>       do libraries just sit on the hard disk until they're called for
 491  <seidos>       no sorry, will focus on that now
 492  <bgs100>       np
 493  <bgs100>       But don't run, okay? :p
 494  <Snova>        seidos: when you run firefox, Linux reads it off the disk; a program called the dynamic linker reads the necessary libraries off of disk and "links" them to the binary, then proceeds to continue execution of firefox
 495  <seidos>       bgs100, compiled
 496  <bgs100>       Okay
 497  <bgs100>       seidos, Run: echo "Hello, gentlemen! What a fine day it is" | ./whateveryounametheexecutable
 498  <seidos>       Snova, sounds like DLLs in windows.  What came first libraries in Unix or libraries in Windows?
 499  <Snova>        seidos: unix is much older
 500  <seidos>       bgs100, can I copy and paste?
 501  <bgs100>       No
 502  <bgs100>       Replace ./whateveryounametheexecutable with whatever you named the executable
 503  <seidos>       I didn't think so.  I typed it out.
 504  <seidos>       it capitalized it
 505  <bgs100>       and?
 506  <Snova>        seidos: also, "DLL" is pretty much the same thing as "shared library"
 507  <bgs100>       seidos, What about the exclamation mark?
 508  <seidos>       there are four exclamation marks
 509  <bgs100>       Okay
 510  <bgs100>       Good
 511  *      seidos wonders if firefox would run faster without gnome running
 512  <Snova>        seidos: not likely
 513  <Snova>        technically yes, but not to a degree anyone would really notice
 514  <seidos>       yeah.  I don't know why.  firefox seems sluggish to me
 515  <seidos>       I think it would be faster on windows, but I could be trippin'
 516  <bgs100>       Okay
 517  <Snova>        there would be fewer processes sharing the CPU (even though most of them are idle), more memory available, and the X server would be doing less, but none of that will have much of an impact
 518  <bgs100>       seidos, In this, we introduce 4 new things
 519  <seidos>       but my install of ubuntu is kind of a hack too
 520  <bgs100>       getchar, putchar, EOF, and ctype.h/toupper
 521  <bgs100>       So,
 522  <seidos>       I noticed ctype.h and toupper
 523  <seidos>       but not getchar, putchar, EOF
 524  <bgs100>       seidos, getchar gets one character from input.
 525  <bgs100>       However
 526  <bgs100>       No characters are "submitted" until you press enter
 527  <bgs100>       And
 528  <bgs100>       You will notice that "c" is an integer,
 529  <bgs100>       as opposed to a char (standing for "character"),
 530  <bgs100>       because EOF is equal to -1, which characters can't hold
 531  <bgs100>       seidos, Okay?
 532  <seidos>       okay
 533  <bgs100>       EOF means End of File, btw
 534  <Snova>        er, technically they can, but the problem is getchar() can otherwise return anything from 0 to 255- so would otherwise be possible to send it a fake EOF if getchar() returned one byte
 535  <bgs100>       >_>
 536  <Snova>        what? you're wrong :)
 537  <seidos>       yeah, EOF is end of file, knew that
 538  <bgs100>       Snova, ssshhhhhhh
 539  <bgs100>       :P
 540  <Snova>        orite, teachers are always correct
 541  *      Snova sits in the corner
 542  <seidos>       Snova, how do you learn about programming?
 543  <seidos>       bgs100, and how did you learn?
 544  <bgs100>       Snova, Yeah, I don't want to remove any possible illusions of a wizards C hacker with a long beard.
 545  <bgs100>       wizardly*
 546  <Snova>        seidos: a book, the internet, and a few years of tinkering
 547  <pedro3005>    back
 548  <pedro3005>    sorry
 549  <bgs100>       seidos, Help on IRC and the K&R
 550  <seidos>       maybe I should check out a book from the library.  I'm currently trying to read Darwin
 551  <seidos>       bgs100, K&R?
 552  <bgs100>       seidos,
 553  <bgs100>       http://en.wikipedia.org/wiki/The_C_Programming_Language_%28book%29
 554  <seidos>       haha that c variable throws me off a little
 555  <bgs100>       It's written by guys who created Unix and C (correct, Snova?)
 556  <bgs100>       Hai pedro3005
 557  <pedro3005>    bgs100, did you explain the code yet?
 558  <bgs100>       pedro3005, Which example?
 559  <seidos>       I don't think my library would have this book
 560  <bgs100>       seidos, :[
 561  <seidos>       whoa, this book is a tome!  I wasn't even born when it was written
 562  <bgs100>       I very very luckily got it at a yard sale for 50 cents
 563  <Snova>        bgs100: yeah, I think so
 564  <pedro3005>    bgs100, the last one
 565  <seidos>       they might have it or something like it
 566  <Snova>        as I recall C was invented *for* unix
 567  <pedro3005>    I have this book, the second edition
 568  <bgs100>       pedro3005, Doing so now
 569  <bgs100>       pedro3005, So do I
 570  <bgs100>       :D
 571  <seidos>       it's too bad good quality books aren't available for free on the Internet
 572  <pedro3005>    well, actually I "borrowed" it from my dad
 573  <bgs100>       pedro3005, lol
 574  <bgs100>       I bought the book with my own hard-earned 50 cents
 575  <pedro3005>    bgs100, ... 50 cents?!
 576  <seidos>       I used to have a c++ book when I took a class in college
 577  <bgs100>       ;D
 578  <bgs100>       In fact
 579  <pedro3005>    bgs100, where do they sell books this cheap?
 580  <seidos>       I should've kept it
 581  <bgs100>       pedro3005, That was double the original price
 582  <bgs100>       I decided to donate an extra quarter
 583  <seidos>       all right, I think I need to program something
 584  <seidos>       but what?
 585  *      seidos ponders
 586  <bgs100>       pedro3005, Lol I got it from my local church's yard sale
 587  <seidos>       I'll program my depression calculator
 588  <bgs100>       xD
 589  <bgs100>       Anyway
 590  <bgs100>       ON WITH THE EXPLANATION
 591  <bgs100>       We love getting side-tracked here
 592  <bgs100>       :p
 593  <bgs100>       seidos, pedro3005 Okay,
 594  <bgs100>       putchar prints one character out.
 595  <bgs100>       so yeah
 596  <pedro3005>    seidos, gonna need a 'long long' for that one
 597  <pedro3005>    :P
 598  <bgs100>       lol
 599  <bgs100>       And
 600  <bgs100>       toupper(0 takes in a character and makes it uppercase (with letters)
 601  <bgs100>       toupper()*
 602  <seidos>       do you have to put "int main ()" or will "main ()" work?
 603  <pedro3005>    Oh, cool
 604  <bgs100>       main() technically will
 605  <bgs100>       But it's not good style.
 606  <seidos>       okay
 607  <bgs100>       alright
 608  <Snova>        seidos: "main()" is old-style; most compilers will accept it if they feel forgiving, but it's not technically valid anymore afaik
 609  <Snova>        it's from the days where, if you didn't specify a return type/variable type, it was int by default
 610  <bgs100>       then, we check if c is the character '!' ('blah' represents a character as the actual character in C),
 611  <bgs100>       and if so print out three additional exclamation marks
 612  <bgs100>       So yeah, we're just transforming input here.
 613  <bgs100>       seidos, pedro3005 Any questions?
 614  <bgs100>       er, brb
 615  <seidos>       bgs100, not really
 616  <bgs100>       nvm
 617  <bgs100>       Snova, Any questions? :P
 618  *      bgs100 scans room for questions
 619  <pedro3005>    you know you have to delete someone from your msn when you receive this
 620  <pedro3005>        [21:42:46] ­I <3 twilight
 621  <bgs100>       ...
 622  <bgs100>       That is not a question.
 623  <bgs100>       :p
 624  <seidos>       pedro3005, gagaga
 625  <seidos>       that's how I laugh
 626  <seidos>       "gagaga"
 627  <seidos>       I'm team Justin personally
 628  <seidos>       I think edward is too gay
 629  <bgs100>       ...
 630  <seidos>       everyone knows werewolves are cooler than vampires
 631  <seidos>       pedro3005, ^^
 632  <bgs100>        /* */ (no comment)
 633  <seidos>       haha
 634  <Snova>        bgs100: this is clearly a comment; also seidos is right
 635  <bgs100>       Snova, About what? :|
 636  <Snova>        well, maybe not; depends on the rendition
 637  <bgs100>       ...
 638  <pedro3005>    bgs100, no questions about the code
 639  <Snova>        back to 99 I think
 640  <bgs100>       ?
 641  <bgs100>       Snova, ...?
 642  <seidos>       Snova, something is wrong, I'm never right
 643  <bgs100>       pedro3005, okay
 644  <Snova>        seidos: you're left?
 645  <bgs100>       lol
 646  <seidos>       Snova, haha, didn't get that for a second
 647  <seidos>       well, maybe like 5 seconds
 648  *      bgs100 turns seidos around
 649  <bgs100>       Now that you're right do you get it quicker? :P
 650  *      seidos looks around uneasily
 651  <seidos>       I'm ambidextrous
 652  <bgs100>       Seriously?
 653  <seidos>       and I'm always confused
 654  <seidos>       I can type with both hands :D
 655  <bgs100>       Lol
 656  <seidos>       bgs100, HW?  You said we'd go over it at the end
 657  <bgs100>       ...anyway... if we are done with both Twilight and directions
 658  <bgs100>       seidos, You're ready for the end? :p
 659  <bgs100>       Okay
 660  <bgs100>       seidos, pedro3005 Homework, please?
 661  <seidos>       I'm ready for something
 662  <pedro3005>    bgs100, sure
 663  <seidos>       I should really start using gedit
 664  <seidos>       I can't copy a full page in vim
 665  <seidos>       bgs100,  http://paste.ubuntu.com/452257/
 666  <pedro3005>    bgs100, oh, right, I was supposed to link you my homework
 667  <Snova>        hm, I don't think &* is necessary. you just get what you started with
 668  <Snova>        it dereferences a pointer and then takes its address again; you just get an identical pointer
 669  *      pedro3005 quickly removes it from his code
 670  <bgs100>       Lol
 671  <seidos>       Snova,  I'll take it out and try it
 672  <pedro3005>    bgs100, http://paste.pocoo.org/show/227453/
 673  <bgs100>       seidos, Good, no compiler warnings with wall and it works correctly.
 674  <bgs100>       pedro3005, Good, also no compiler warnings and functional
 675  <bgs100>       Also, yay for indenting
 676  <seidos>       Snova, I get  warning when I take out the &
 677  <pedro3005>    bgs100, python trashed me for good :D
 678  <bgs100>       I notice that you scanf("%d",&toGuess); to scanf("%d",toGuess); because now toGuess is already a pointer
 679  <bgs100>       seidos, No, take out the & and the *
 680  <seidos>       Snova, oh, I have to take out both &*
 681  <bgs100>       Although seidos has spaces between function arguments
 682  <Snova>        seidos: if you only took out that, you'd be dereferencing a pointer with the remaining *, which would go from int* to int. scanf expects an int* though
 683  <bgs100>       (which is good :p)
 684  <bgs100>       A+'s for both of you :D
 685  *      bgs100 gives seidos and pedro3005 stars
 686  <seidos>       I don't think I understand what the & is for
 687  <Snova>        seidos: goes the other way around; takes an int's address to get an int*
 688  <bgs100>       seidos, getting the location of something in memory
 689  <Snova>        seidos: so &* effectively does nothing; you go from int* to int and then back to int*
 690  <seidos>       I think I just found the greatest placebo
 691  <seidos>       playing
 692  <seidos>       like I can pretend I'm praying like He-man with his sword and grayskull and junk
 693  <seidos>       hehehe
 694  *      seidos is crazy
 695  <seidos>       all right, doesn't really make sense
 696  <seidos>       in fact, I'm surprised I got a good grade on my assignment
 697  <pedro3005>    bgs100, so, moar? :p
 698  <Snova>        it's only been two hours :p
 699  <pedro3005>    it felt like nothing!
 700  <bgs100>       Lol
 701  <seidos>       whoa it's been two hours?!
 702  <bgs100>       pedro3005, You were gone for at least 30 minutes xP
 703  <pedro3005>    I mean, we only really learned about fopen and getchar
 704  <bgs100>       Okay maybe not 30
 705  <bgs100>       wwwhhhhaaatttt
 706  <bgs100>       0_o
 707  <pedro3005>    what else did we learn about?
 708  <seidos>       I would have to go back to the code to see what I "learned"
 709  <seidos>       ctype.h?
 710  <Snova>        pedro3005: idt's, but you weren't there
 711  <seidos>       rehashed pointers
 712  <pedro3005>    Snova, wha?
 713  <Snova>        oh, we didn't? well then
 714  <bgs100>       pedro3005, Um, I was hoping you learned about files, a bit more about pointers, some file operating functions, getchar, putchar, ctype.h and toupper
 715  <seidos>       not even I remember idt's
 716  <bgs100>       At least.
 717  <pedro3005>    bgs100, I did
 718  <seidos>       man which one did we do functions in?
 719  <seidos>       oh yeah, toupper
 720  <seidos>       forgot about that one
 721  <bgs100>       That is not "fopen" and "getchar" :p
 722  *      bgs100 thinks pedro3005 is making little of his generous use of time. *hmpf*
 723  <bgs100>       (jk :p)
 724  <bgs100>       Okay
 725  <pedro3005>    bgs100, I did learn all of these!
 726  <pedro3005>    you can try me
 727  <pedro3005>    right now
 728  <pedro3005>    I'LL TAKE THE TEST RIGHT NOW
 729  *      pedro3005 takes shirt off
 730  <bgs100>       pedro3005, What's the square root of 7584378943757435784326786578436584365763241632?
 731  <seidos>       we should probably take a test, so I can epically fail it
 732  <seidos>       I don't even think my computer can calculate that
 733  <Snova>        pedro3005: compute the square root of that number through continued approximation, using only bitwise operators
 734  <seidos>       hey Snova, is there a class for the "teachers" like you and bgs100?  taught by Eric Hammond or something?
 735  <bgs100>       pedro3005, How many bits would it take to represent a google?
 736  <bgs100>       seidos, ?
 737  <seidos>       333
 738  <pedro3005>    bgs100, 2^333
 739  *      bgs100 doesn't know who that is...
 740  <bgs100>       pedro3005, No, it only takes 33 bits :P
 741  <seidos>       I think it's 333 bits
 742  <bgs100>       333*
 743  <seidos>       not 2^333 bits
 744  <pedro3005>    damn
 745  <bgs100>       seidos, Correct
 746  <Snova>        hehe
 747  <bgs100>       2^333 is quite a bit larger than 333
 748  <bgs100>       Around a google, I hear. :p
 749  <seidos>       pedro3005, better luck next time chummmmm-p
 750  <pedro3005>    :(
 751  <seidos>       no frowny faces, it's the first time I've *ever* got a question that you didn't
 752  <seidos>       quite frankly it's kind of cheating, since I asked the original question
 753  <bgs100>       Lol
 754  <seidos>       no glory for seidos :|
 755  *      bgs100 gives seidos the Test-Winnar (misspell intentional) award
 756  <bgs100>       You are now a Winnar
 757  <seidos>       more questions!
 758  *      Snova gives bgs100 the Spellar award
 759  <bgs100>       Wie thank yuo
 760  <bgs100>       :P
 761  <seidos>       I know a question I still don't remember.  what is the general form equating logs and exponents?
 762  *      bgs100 gives Snova the Sarkastic Award Award
 763  *      seidos looks at his notes
 764  <bgs100>       seidos,
 765  <seidos>       I can't remember it for the life of me
 766  <seidos>       bgs100
 767  <bgs100>       wait
 768  <bgs100>       Do you mean in C?
 769  <seidos>       waiting...
 770  <bgs100>       seidos, ^
 771  <seidos>       no, just in general
 772  <bgs100>       Oh
 773  <Snova>        seidos: if x^y = z then x log z = y
 774  <seidos>       I only know of pow() in C
 775  <bgs100>       Okay
 776  <bgs100>       Homework
 777  <seidos>       I have if x = b^y then y = log(base b) x
 778  <bgs100>       pedro3005, Are you around?
 779  <Snova>        seidos: sure
 780  <bgs100>       Well
 781  <Snova>        I think the "mathematical" notation is "x log z" but however you remember it
 782  <pedro3005>    bgs100, yes
 783  <seidos>       x log z?  that sounds like x * log base z
 784  <seidos>       I got it from wikipedia
 785  <bgs100>       Here's the homework, suggested by our resident Assistant teacher and Award Givzer:
 786  <bgs100>       Make a program that transforms input by making every other character uppercase.
 787  <bgs100>       FOR BONUS POINTS,
 788  <Snova>        ah, wikipedia uses a subscript, which makes sesne
 789  <bgs100>       Make the program also ensure that every other letter is lowercase,
 790  <bgs100>       aaannnddd
 791  <bgs100>       *thinks of other bonus*
 792  <bgs100>       At the end tell the length of the input.
 793  <bgs100>       (that is, after EOF is recieved)
 794  <bgs100>       Okay?
 795  <seidos>       yeah, I typed that in my file already
 796  <pedro3005>    LiKe ThIs?
 797  <bgs100>       Not quite
 798  <bgs100>       LiKe tHiS?
 799  <bgs100>       Because
 800  <Snova>        spaces count
 801  <bgs100>       it would have tried to uppercase the whitespcae
 802  <Snova>        even though you can't uppercsae/lowercase them
 803  <bgs100>       whitespace*
 804  <bgs100>       Yes, what Snova said :p
 805  <pedro3005>    bgs100, so we fix that bug :p
 806  <bgs100>       pedro3005, Okay, extra bonus, I guess
 807  <bgs100>       alright?
 808  <Snova>        pedro3005: see also isspace()
 809  <bgs100>       Everyone good on homework?
 810  <pedro3005>    alright, I'll work on it
 811  <pedro3005>    Snova, sure, thanks
 812  <bgs100>       Snova, pedro3005 and isalpha()
 813  <pedro3005>    I know that one
 814  <Snova>        perhaps
 815  <Snova>        depends on how you want to do it, I guess
 816  <bgs100>       yeah
 817  <bgs100>       Okay
 818  <bgs100>       seidos, Questions?
 819  <bgs100>       meh, I'll take questions after class
 820  <bgs100>       ======================== BEGIN DISMISSAL OF CLASS! ==============================
 821  <bgs100>       ;p
 822  <bgs100>       I'll see you all Monday, have a nice, uh, Saturday
 823  <bgs100>       (just kidding)
 824  <seidos>       thank you bgs100
 825  <seidos>       no questions
 826  <bgs100>       Alright, cool
 827  <bgs100>       :)
 828  <pedro3005>    thanks bgs100
 829  <bgs100>       You're welcome. Thank Snova, too :p
 830  <pedro3005>    thanks Snova
 831  <pedro3005>    :p
 832  <seidos>       thanks Snova

learners/19062010 (last edited 2010-06-20 04:38:13 by 117)