C user input ⌨️

Поделиться
HTML-код
  • Опубликовано: 12 июн 2024
  • C how to accept user input scanf fgets tutorial example explained
    #C #user #input
    char name[25]; //bytes
    int age;
    printf("
    What's your name?");
    //scanf("%s", &name);
    fgets(name, 25, stdin);
    name[strlen(name)-1] = '\0';
    printf("How old are you?");
    scanf("%d", &age);
    printf("
    Hello %s, how are you?", name);
    printf("
    You are %d years old", age);
  • НаукаНаука

Комментарии • 47

  • @BroCodez
    @BroCodez  2 года назад +16

    #include
    #include
    int main(){
    char name[25]; //bytes
    int age;
    printf("
    What's your name?");
    //scanf("%s", &name);
    fgets(name, 25, stdin);
    name[strlen(name)-1] = '\0';
    printf("How old are you?");
    scanf("%d", &age);
    printf("
    Hello %s, how are you?", name);
    printf("
    You are %d years old", age);
    return 0;
    }

    • @thegamingpaul3743
      @thegamingpaul3743 2 года назад

      how about the birthdate?

    • @TodiDiang
      @TodiDiang 11 месяцев назад +1

      How about this
      #include
      int main() {
      char input1[100];
      char input2[100];

      printf("Input 2 (without space): ");
      scanf("%s", input2);
      printf("Input 2: %s
      ", input2);

      // Clearing input buffer
      while (getchar() != '
      ');

      printf("Input 1 (with space): ");
      scanf("%[^
      ]", input1);
      printf("Input 1: %s
      ", input1);

      return 0;
      }
      My friend using that code

  • @annoyingprecision2487
    @annoyingprecision2487 11 месяцев назад +2

    This was a splendid lesson on user input in C. Thanks a ton.

  • @eeneemeenee6236
    @eeneemeenee6236 8 месяцев назад +1

    i like that u mention the gap in knowledge at certain parts

  • @TheScissorunner
    @TheScissorunner Год назад +2

    Great production quality with your videos!

  • @shiwari1280
    @shiwari1280 2 года назад

    Thanks for the tutorials bro!

  • @pakapeta7772
    @pakapeta7772 2 года назад

    Very useful, cheers mate.

  • @fabiovictorino350
    @fabiovictorino350 2 года назад

    Very simple and good.

  • @t-ree
    @t-ree 2 года назад

    Thank You!!

  • @ghazihattab
    @ghazihattab 2 года назад

    ur the best :)

  • @Grab-Deals
    @Grab-Deals 2 месяца назад

    Great

  • @azeedhazard7638
    @azeedhazard7638 Год назад

    amazing bro👍

  • @ShStepan
    @ShStepan 2 года назад

    fgets(); Which autocomplete do you use for that?

  • @cadmium4113
    @cadmium4113 2 года назад

    Bro❤️

  • @sashaktyadav7998
    @sashaktyadav7998 2 года назад +1

    I asked you a question that Which language is best for making mobile app than can control robots (Both iphone and android) ? Pls reply sir 🙏

    • @BroCodez
      @BroCodez  2 года назад +2

      Python with Kivy framework could work

  • @user-mc9uv7ij7x
    @user-mc9uv7ij7x Год назад

    ❤❤❤❤

  • @not_pockchan3418
    @not_pockchan3418 2 года назад +1

    noice, the string format also doesn't seem to advanced, great teaching bro

  • @MerryMerry632
    @MerryMerry632 7 месяцев назад

  • @nem0103
    @nem0103 2 года назад +1

    when i press run it direct to output and not terminal. how to run it??

  • @pamlongwood4217
    @pamlongwood4217 8 месяцев назад

    legend

  • @user-ace96plays
    @user-ace96plays 25 дней назад

    DONE❤

  • @harshitpandit188
    @harshitpandit188 2 года назад

    Hi bro. I've been watching Java tutorial from your series only.Please help me with the setup of Java in Visual Studio Code
    Also are you planning any series on android development ??

  • @thiemhoang3015
    @thiemhoang3015 2 года назад +1

    how can run in the black console like visual studio ??

  • @felipemrj.
    @felipemrj. Месяц назад

    yoooooooooooo

  • @yuhmi88
    @yuhmi88 2 года назад

    early!

    • @yuhmi88
      @yuhmi88 2 года назад

      thx for noticing!

  • @Onestonedbake
    @Onestonedbake 7 месяцев назад

    wazzup bro code!!! im new to the community!!!

  • @khahanguyen3059
    @khahanguyen3059 2 года назад

    how can run input in mac os, because it isn't like your video.

  • @aditya_asundi
    @aditya_asundi 2 года назад

    Why vscode? Why not dev-c++, vs19 or codelite?

    • @BroCodez
      @BroCodez  2 года назад +1

      more people are transitioning to vscode

    • @Unit_00
      @Unit_00 2 года назад +7

      lmao and here I am using notepad

    • @dxshawn532
      @dxshawn532 Год назад

      Those are trash

  • @rezuwankabir3372
    @rezuwankabir3372 Год назад

    can you not just do scanf ("%s%s", &nameF, nameL) instead of using fgets?

  • @big_2361
    @big_2361 2 года назад

    he scanfs the string with an & and it works? how?

    • @redemedy8602
      @redemedy8602 2 года назад

      if you dont put it it will modify the pointer so...

    • @big_2361
      @big_2361 2 года назад

      @@redemedy8602 no not at all. with int or char variables you use & to get their address aka get a pointer to them and change the value at which the pointer points. if you assign a pointer to a pointer with & you will only change the pointer (you will change where it points to) and that will cause an error

    • @vincenzo3574
      @vincenzo3574 2 года назад

      It works because &array is equal to array in C, if he was using a pointer to a buffer allocated with malloc it would crash

  • @HyProDuxyMusicHandle
    @HyProDuxyMusicHandle 10 месяцев назад

    am not 21 anymore but i pretend i still am!

  • @vega_yy
    @vega_yy 2 месяца назад

    printf("Random comment1.2");

  • @fyrukmcoo100
    @fyrukmcoo100 2 года назад

    :((

  • @engirckt5410
    @engirckt5410 2 года назад

    oh my god c is not like java at all lol

  • @sashaktyadav7998
    @sashaktyadav7998 2 года назад

    I asked you a question that Which language is best for making mobile app than can control robots (Both iphone and android) ? Pls reply sir 🙏