C Programming Tutorial - 9 - I Need Arrays

Share
Embed
  • Published on Aug 4, 2014
  • Facebook - TheNewBoston-464114846956315/
    GitHub - github.com/buckyroberts
    Google+ - plus.google.com/+BuckyRoberts
    LinkedIn - www.linkedin.com/in/buckyroberts
    reddit - www.reddit.com/r/thenewboston/
    Support - www.patreon.com/thenewboston
    thenewboston - thenewboston.com/
    Twitter - bucky_roberts

Comments • 314

  • Madhav Trivedi
    Madhav Trivedi 2 months ago

    2:30 .. :(
    char name[14];
    name = "Bucky Roberts";
    printf("My name is %s", name); this code shows an error..

    • Peterolen
      Peterolen Month ago

      You can't assign to an array.

    • David S
      David S 2 months ago

      Include string h

  • Ismail Chaabane
    Ismail Chaabane 5 months ago

    Thank you so much

  • Badr Chaouch
    Badr Chaouch 7 months ago

    The array size is the size of the elements of the same type but not the number of bytes because the size of a single character is not one byte.

    • Peterolen
      Peterolen Month ago

      The size of the char data type is one byte. Depending on what text encoding is used some visual characters might require multiple bytes.

  • LordLinux689
    LordLinux689 7 months ago

    tnx buzky

  • Dan
    Dan 8 months ago

    how did strcpy work when you didn't include the header file string.h?

  • YungNut
    YungNut 8 months ago +1

    Nice pun in the title. You need a raise? You're fired, get outta here.

  • ghadir fwz
    ghadir fwz 9 months ago

    You're amazing!!

  • samir pant
    samir pant 10 months ago

    man you re better than my university teacher

  • Bhairus Gaming
    Bhairus Gaming 10 months ago

    *buzky roberts*

  • Alexander Bourne
    Alexander Bourne 11 months ago

    puns galore!!

  • ROMBO
    ROMBO Year ago

    Why we didn't just use food as a variable
    And put food = ....

  • jayaprakash reddy

    what is the use of array????

  • Hitesh Choudhary
    Hitesh Choudhary Year ago

    If i put char name[13] = "buckey robert";
    then what value will be stored in name

  • nano tech
    nano tech Year ago

    Thanks for the videos, I seem to understand C a little better now.

  • Sanketh K.P
    Sanketh K.P Year ago

    In int instructions we declare variable first and initialize the value to it latter can we do it for char instruction if it can be done please give example program

  • Rishav Maheshwari

    2 millions.

  • Socarno Amr
    Socarno Amr Year ago

    isn't food initialized with 4 bytes hence the size of tuna! how comes bacon that is 5 bytes fits in there?

    • Peterolen
      Peterolen Year ago

      food is actually 5 bytes because it needs to store a null character '\0' to mark the end of the string, but you are right, "bacon" does not fit. It requires 6 bytes.

  • Harsh Rathi
    Harsh Rathi Year ago

    Anyone pls help me out... 😕
    When i try to change buzky from bucky using code as told by him, it got change to bu4ky. Dont know why? i.e.
    Name[2]="z";
    Printf(" my name is %s \n, name) ;

    • Peterolen
      Peterolen Year ago

      Does that even compile? "z" should be 'z'

  • Yash Bhambhu
    Yash Bhambhu Year ago

    who are these 23 people.

  • ankit raj
    ankit raj Year ago

    #include
    #include
    int main()
    {
    char name[10]="Ankit Raj";
    printf("my name is %s \n", name);
    return 0;
    }
    my program wont run?????

  • DarkChocolate33
    DarkChocolate33 Year ago

    I put strcopy(food, "tuna); and it did not work for me lmao. Glad that I fixed it.

  • Kashish
    Kashish Year ago

    Pls show only the useful part of the screen because the things you type are a pretty difficult to read.. thank you

  • chaitanya koribilli

    bro increase the font size in the compiler u r using

  • kenneth tey
    kenneth tey Year ago

    After I build and run there's ':' at the end, why is that? Can someone please help me

  • TheDarkHorseUprising

    remember to only use single quotes when changing one item in the array.

  • Masztufa Ä.
    Masztufa Ä. Year ago

    some notes i'd like to share while messing around.
    In this IDE if i put
    char name [6] = "Bruce"
    printf(name)
    Then it works just as you expect.
    If i change the length of the array from 6 to 5, then it works exactly the same way.
    If i leave it at a length of 6, then change the value of item 6 in the array to 'h', then it would print out "Bruceh"
    If you change the 6 to 4 then it would print out "Bruc"
    This makes me feel that you don't need to leave an extra byte for the terminator. At least in this IDE.

  • saief zaneti
    saief zaneti Year ago

    Not any programming language ....

  • Omprakash Kalwa
    Omprakash Kalwa Year ago

    I am doing this stuff on tablet and the app name is cppdroid but I am facing problems in using strcpy

  • Yash Khandelwal
    Yash Khandelwal Year ago

    What is basically the meaning and use of arrayyy

  • Am mj
    Am mj Year ago

    I did that strcpy thing but it declares it to be an error I.e not declared

  • Gian Luca De Lillo

    Thank You, Bucky !!

  • Infinity Inc.
    Infinity Inc. Year ago

    Correct me if I'm wrong but you contradicted yourself here. One minute you said you have to define how much space is needed next minute you don't?

  • four one
    four one Year ago

    Bucky: thank you x1000 for not being that one guy who overcomplicates everything. You're a really good teacher and I have learned a ton from your videos. Keep it up man

  • Anonymous
    Anonymous Year ago

    Ok why am I getting an "incompatible pointer to integer conversion" error? I'm running from my terminal on my mac

  • Danny_Programs !
    Danny_Programs ! Year ago

    If Computers start counting from zero, shouldn’t you need to count the bytes in zero too? Thanks BTW! 😃

  • Alexander David Ipsen Pedersen

    Why is ' and not " used arround z @2 min?

    • Peterolen
      Peterolen Year ago

      Because it's a character and not a string (i.e. array of characters).

  • shafiya 2818
    shafiya 2818 Year ago

    ur awesome

  • Tahmid Islam
    Tahmid Islam Year ago

    why din't u put number during printing Tuna????
    how to print only The bacon part and not the tuna part?

  • Rithik Sharma
    Rithik Sharma Year ago

    How can we again use the food as tuna after using strcpy function?

  • GMByte Java
    GMByte Java Year ago

    Buzky sounds like Wasky :D If you know whom I mean.

  • Quentin Lucas
    Quentin Lucas Year ago

    When I try to use strcpy I receive a "Thread 1: signal SIGABRT" error. As far as I can tell, it as something to do with assigning multiple values to "food" within one program. Any suggestions? Great vid, by the way.

    • Peterolen
      Peterolen Year ago

      Bucky made a mistake in the video. The array need to be big enough to hold the string that is being copied.

  • Suman bakali
    Suman bakali 2 years ago

    what is \o

    • Peterolen
      Peterolen Year ago

      \0 is the null character. It marks the end of the string.

  • Nimrod Crawford
    Nimrod Crawford 2 years ago

    I kept getting bugs in my strcpy portion of my program so I did alittle digging and figured out the library needed to be included, is there something wrong in my setup?

    • Peterolen
      Peterolen Year ago

      Nothing wrong. If you use strcpy you should include . It might work without it if the other headers that are being included also includes internally but this is nothing you should rely on.

  • shivaa minocha
    shivaa minocha 2 years ago

    I tried to write a similar program where i start with my name. you said to give one extra byte for the terminator whereas when i do that i get an extra M printed out. so when i actually took 13 bytes instead of 14 it printed out my name. and yes i am doing this on codeblocks.
    Another doubt would be that why did you use 'z' istead of "z" while storing the value in a array

    • Peterolen
      Peterolen Year ago

      'z' is a character. "z" is a string.
      In the program he wanted to set the third *character* of the string to z so that's why he used 'z'.

  • Tom Ashton
    Tom Ashton 2 years ago

    What accent is this?

  • Laurelindo
    Laurelindo 2 years ago

    I love how Bucky calls everything "stupid" and "crap", lol.

  • Bailey Harrison
    Bailey Harrison 2 years ago

    So when you define the size of the array 'name[14]' you count the byte size from 1 but when selecting elements you count from 0?

  • Home Tube
    Home Tube 2 years ago

    You are really cool bucky or BUZKY!! Love all your videos!

  • Osmifor Centrio
    Osmifor Centrio 2 years ago

    What about 13 and 14th element of the array

  • Darshan G
    Darshan G 2 years ago

    how can we change the 2 letters of a word at a single time as we changed 'c' to 'z'

  • E Garam
    E Garam 2 years ago

    c-section, bytes of tuna hehe what's next?
    Me and my friend are started watching these lectures from last week and we tacitly agreed to call it as a c-section.

  • ashish
    ashish 2 years ago

    how can we create an array for storing number? is it even possible? do we even have to do it that way? is just creating a variable enough?

  • TheHades Hell
    TheHades Hell 2 years ago

    what is difference between writing and not writing bytes no. after char in bracket?

  • Sachiyo Daley
    Sachiyo Daley 2 years ago

    Hey does anyone know if printf(name[2]); should run successfully and print a 'z' if placed at the end of the code?
    My computer doesn't seem to like it and keeps saying not responding :/
    I close the "not responding" message and it has the rest of the code but not that that bit, anybody know why??

  • Sheikh Spear
    Sheikh Spear 2 years ago +1

    Man i am using DEV by bloodshed ; it shows an error on
    strcpy(food,"tacos");
    printf("The best food is %s\n" , food);

  • takeng pame
    takeng pame 2 years ago

    I m try of seeing ur ads

  • sadeq ghannam
    sadeq ghannam 2 years ago

    #include
    #include
    int main()
    {
    char nsme [13] = "sadeq ghannam";
    printf("my name is %s \n","name");
    return 0;
    }
    the output will be my name is name
    lol can someone figure why ?

  • Kepler
    Kepler 2 years ago

    name[2] = "x"; Doesnt work. Invalid conversion from "const *char" to "char".. Memory related.

  • Minju Kang
    Minju Kang 2 years ago

    It's really good video!!
    But I can't understand why we need to use keyword 'strcpy'
    why do we have to use 'strcpy' without just creating another array?

  • Shehwar's Studio
    Shehwar's Studio 2 years ago

    hey buddy, I did the thing that is shown here which changes a particular letter in a string but I got a "?" instead of the replacement character that I typed in.

    for example taking the video's example :
    my name is "Bu?ky Roberts"
    any help is highly appreciated !

    • Shobhit Behl
      Shobhit Behl Year ago

      char[some number]='some letter'... you must have used ""(double quotes) instead of ''(single quotes).
      I hope that answers your query.