Objective C Programming Tutorial - 13 - scanf and increment operators

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น • 62

  • @deltavaudio6323
    @deltavaudio6323 6 ปีที่แล้ว +1

    Bucky, my man you are a legend! Your talent for teaching is on the level of the Khan Academy dude. I wish you the best of success in whatever you do.

  • @truthsmiles
    @truthsmiles 13 ปีที่แล้ว

    Hey, Bucky - I just want to say thanks for putting in all the work of doing this. You're an excellent teacher. I'm learning so much watching them!

  • @TheStoneGolem13
    @TheStoneGolem13 14 ปีที่แล้ว

    @Brandlax
    You can also end any loop by typing "break;" an example would be
    "if (x==3) break;" then the program would get out of the loop when x is equal to 3

  • @JTedam
    @JTedam 14 ปีที่แล้ว

    hi bucky,
    you can avoid appearing to look to your left anytime you check to your remind yourself of what to teach by placing the monitor above the camera. That way, you will still appear to be looking at the listener (just like a teleprompter). You're awesome!

  • @Connador
    @Connador 13 ปีที่แล้ว

    I just want to say thanks, I'm switching over from C++ which is a bit difficult since I'm used to everything being a certain way. You've made it very easy to understand. :)

  • @matnelson1
    @matnelson1 14 ปีที่แล้ว

    These videos are great! You explain what its all about unlike most other videos.

  • @Jstall311
    @Jstall311 13 ปีที่แล้ว

    The difference between i++ and ++i is not just personal preference. When used in code putting the ++ after the variable returns the current value and increments the variable by one. Putting the ++ before the variable increments the variable by one THEN returns the value. This is irrelevant when used in a for loop but could result in unexpected results when you try to use it elsewhere.

  • @tyebillion
    @tyebillion 11 ปีที่แล้ว +1

    i++ is post increment. ++i is pre increment. For example:
    int i = 3;
    NSLog(@"%i", i++); // outputs 3
    NSLog(@"%i", i); // outputs 4
    NSLog(@"%i",++i); // outputs 5
    NSLog(@"%i", i); // outputs 5
    I don't think it makes any difference when used in a for loop step.

  • @triniclemist90
    @triniclemist90 14 ปีที่แล้ว

    @livewithdavid I was just about to post the same thing. That seems to be a commonly misunderstood idea when someone is learning to program.
    One other thing, You can do increment adjustments on characters. What it does it adds one binary digit to the letter, making it one higher. So if:
    char a='a';
    a++;
    NSLog(@"%c",a);
    you would get 'b' as your output. This can be used to change the case of a character. to make a lower case letter capital subtract 32, and vise versa.

  • @Theowne
    @Theowne 13 ปีที่แล้ว

    I think for beginners it's best to separate post increment and pre increment and just write it explicitly. It will be easier to keep track.

  • @423santosh
    @423santosh 13 ปีที่แล้ว

    excelllent teaching bucky just amazing anybody can easily grasp it

  • @catomajorcensor
    @catomajorcensor 4 ปีที่แล้ว

    I know that it has been 10 years, but:
    There is a difference between x++ and ++x, x++ is an expression that gives you the value of the variable and then increments it, and ++x is an expression which increments the value and *then* give it to you.
    Also, increment and decrement operators work on pointers as well.
    And, you should really mention that scanf, for loops, and most datatypes came from C.

  • @swallowedinthesea11
    @swallowedinthesea11 11 ปีที่แล้ว

    %c is the wrong conversion; you need to use %s because your name, Rick, is a string. Strings are basically words, anything more than a single character is a string even though a character can be a string, but that's another story.
    scanf("%s", userName);
    NSLog(@"Your name is %s", userName);
    Also an ampersand is not needed when your variable name is a string.

  • @MrAstroKind
    @MrAstroKind 13 ปีที่แล้ว

    @louisdebmusic
    There are equivalent functions, it's just (slightly) bad practice to use i+=1 because adding one to a variable is so common that they (the creators of objective C and C) added i++ to add 1 to the variable, the += is generally used for numbers larger than 1.

  • @lifematch
    @lifematch 14 ปีที่แล้ว

    actually there is a difference between i++ and ++i;
    ++i is telling the computer that add one to whatever variable that is next. and i++ is saying read the variable i then then ++ will add 1 to the variable. they might sound the same but its' actually not. for instance if you do an array of array[count++]; and say count was intialise as 0; then they will look at array[0] but after that count become 1 and next array[count++] will be array[1]. array[++count] will in this case be array[1].

  • @andyeriksoncomedy
    @andyeriksoncomedy 12 ปีที่แล้ว

    wow, this helped me SO much, thanks! crazy that you can't have a space there.

  • @Wint3rsHowl
    @Wint3rsHowl 12 ปีที่แล้ว

    Thanks for all this videos bucky just wondering if you are going to get into some iphone programming that would be awesome:)

  • @bonesmalin
    @bonesmalin 14 ปีที่แล้ว

    You saved my life with these tutorials. HAHA thank you! GREAT tuts!

  • @rushofspeed
    @rushofspeed 13 ปีที่แล้ว

    hey bucky was up ive been watching your tutorial man i love them seriously
    can you explain to me what a memory leak is at around 5:46. consequences solutions etc.

  • @hawkins1227
    @hawkins1227 13 ปีที่แล้ว

    Dude you are really good...I am learning so much from you!!!
    THANK YOU!!!!!!!!!!

  • @skrela
    @skrela 12 ปีที่แล้ว

    You're awesome Bucky. Keep up the good work!

  • @jeremyklein5661
    @jeremyklein5661 12 ปีที่แล้ว

    I bet you found your mistake already, but I was getting an error about it not complying with ARC as well. I had @"int" as opposed to "int"

  • @robrulez16
    @robrulez16 13 ปีที่แล้ว

    if your using xcode 4, and when inputting your number doesn't do anything, make sure you hold down shift key and then press enter after inputting the number in the console. I was stuck on this for a few minutes.

  • @smith507
    @smith507 12 ปีที่แล้ว

    So, you're saying that the "@" not he NSLog is for Objective-C stuff. then is it valid to use the "printf" from C instead of the "NSLog" ? and if that's the case, what are the benefits?
    Thanks man, awesome video tutorials you have here.

  • @TheCrappyaccount
    @TheCrappyaccount 13 ปีที่แล้ว

    @jljacobjl not really, printf is the c equivalent of NSLog

  • @TheAndy500
    @TheAndy500 13 ปีที่แล้ว

    I had an issue entering the number. Apparently the "return" key works and the "enter" key does not. Just thought I would point it out in case anyone else had the issue. If they're the same key I think you have to hit shift.

  • @jljacobjl
    @jljacobjl 13 ปีที่แล้ว

    love your tutorials, they're awesome. just a question, is there any reason to use NSLog instead of printf?

    • @catomajorcensor
      @catomajorcensor 4 ปีที่แล้ว

      I know that this tutorial was 10 years ago, but there is. Actually there are multiple.
      1. NSLog automatically adds a new line, and printf doesn't, so this can be useful for making a program like the following:
      int main(int argc, const char * argv[]) {
      @autoreleasepool {
      for (int i = 1; i

  • @heisenbergmadethebeat
    @heisenbergmadethebeat 13 ปีที่แล้ว

    worked it out, you can't have a space before &userNum to work in
    Xcode 4 the line has to read:
    scanf("%i",&userNum);
    This gives the cursor

  • @jlr726
    @jlr726 13 ปีที่แล้ว

    I am using Xcode 4 but when I enter in scanf("%i",&userNum); it just add 1 to what ever number I type in. example : I type 21 and it gives me 22

  • @techexxpert
    @techexxpert 13 ปีที่แล้ว

    @Vamp2905 You put a semi colon after the for loop. There shouldn't be one there. Should be like this
    ... i++){
    NSLog(...

  • @Stratomacaster
    @Stratomacaster 14 ปีที่แล้ว

    So when will you be moving on to more advanced tutorials using Objective C ... as in iPhone Apps :-)

  • @mariokid2115
    @mariokid2115 13 ปีที่แล้ว

    You have some nice tuts.

  • @aquaman360
    @aquaman360 14 ปีที่แล้ว

    if you enter a letter instead of number the program will continue to add up numbers.

  • @RussellKasem
    @RussellKasem 13 ปีที่แล้ว

    I wish my professors referenced bacon, they would hol my attention so much better.

  • @Trufflestravels
    @Trufflestravels 11 ปีที่แล้ว

    Ty

  • @marcopfvieira
    @marcopfvieira 13 ปีที่แล้ว

    char bucky;
    sacnf("%i", &bucky);
    : buky is a great teacher!

  • @exelente
    @exelente 12 ปีที่แล้ว

    we love you!

  • @specky532
    @specky532 13 ปีที่แล้ว

    it just prints the number 1 how ever many times, it doesn't inrease

  • @TheGreatOne222
    @TheGreatOne222 12 ปีที่แล้ว

    YA!! I did it!! now tho you dont need to manage the memory

  • @GrandStudable
    @GrandStudable 14 ปีที่แล้ว

    hahahaha you are amazing! it was so funny, i just typed 600 and my console was like OMG this guy wants to kill me

  • @meowsty
    @meowsty 12 ปีที่แล้ว

    how would u prevent people from entering a letter because i put a letter to see if it was allowed and it started to count un stop so i closed Xcode

  • @ma123N47
    @ma123N47 12 ปีที่แล้ว

    does bucky help us create iphone apps later on? are there tutorials for that?
    THx

  • @heisenbergmadethebeat
    @heisenbergmadethebeat 13 ปีที่แล้ว

    scanf wont let me enter a number in console in xcode 4, theres no cursor. It works fine in 3 though :/

  • @MegaZhee
    @MegaZhee 11 ปีที่แล้ว

    what is the diffrence between printf and nslog?

  • @MrAknur
    @MrAknur 13 ปีที่แล้ว

    I have one question....
    Why if we put ";" after "for(i=1;i

  • @canuxfan44
    @canuxfan44 14 ปีที่แล้ว

    @freefox12 I was just going to say this exact same thing, but it looks like you beat me to it.

  • @louisdebmusic
    @louisdebmusic 13 ปีที่แล้ว

    bucky instead of:
    i++
    why can't we use
    i += 1
    like we did before?
    please help

  • @SjN85
    @SjN85 13 ปีที่แล้ว

    which editor do you use?

  • @brandlax
    @brandlax 14 ปีที่แล้ว

    how do u end a for loop?

  • @zulkarnainmislan
    @zulkarnainmislan 12 ปีที่แล้ว

    It's a C++ Language! Luckily this is similar to C++. Easier for me to learn.

  • @Vamp2905
    @Vamp2905 13 ปีที่แล้ว

    Bucky,
    For some reason, although I followed your code flawlessly, my code comes out with the number I input PLUS 1. Why is this? Thanks for all your help!
    :D

  • @technoguy3542
    @technoguy3542 13 ปีที่แล้ว

    scanf works with regular C too, right?

  • @specky532
    @specky532 13 ปีที่แล้ว

    d/w i had a 1 instead of a i somewhere, derp

  • @DeamMe
    @DeamMe 12 ปีที่แล้ว

    You need these "{}"

  • @JIM50
    @JIM50 13 ปีที่แล้ว

    @robrulez16 Thanks a lot i knew i wasnt the only one

  • @sacredgeometry
    @sacredgeometry 14 ปีที่แล้ว

    @freefox12 i was about to say exactly this

  • @disney6858
    @disney6858 12 ปีที่แล้ว

    AND THAT WAS FUNNY
    LMFAO
    :)

  • @googleboy314
    @googleboy314 13 ปีที่แล้ว

    Drop the @, add the &.

  • @DarkOverFlowOverflow
    @DarkOverFlowOverflow 6 ปีที่แล้ว

    awesome scanf??? lol hackers laugh did u know it was and is vulnreable because it doesnt check the lenght