STL std::string, char*, const char*, and string literals in C++ | Modern Cpp Series Ep. 112

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

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

  • @pyajudeme9245
    @pyajudeme9245 Месяц назад +1

    Awesome channel! I started to use C++ in Cython a while ago, and your videos have helped me a lot! Thx!

    • @MikeShah
      @MikeShah  Месяц назад

      Cheers -- I'm happy to hear that!

  • @thestarinthesky_
    @thestarinthesky_ Год назад +4

    @17:12 we might want to do this to get the address . std::cout

  • @yvickmiossec6536
    @yvickmiossec6536 Год назад +7

    Mike’s stuff is excellent. I have learnt many, many things from his videos. Very surprised at the number of views: IMHO, this channel is a fantastic ressource for the programming enthousiast. Thank you Mike !

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

      Cheers, thank you for the kind words 🙂

  • @gandab
    @gandab Год назад +1

    Nice and simple explanation for new programmers going into C++ especially with no C experience beforehand. I noticed that you can get the first char address with something like const char* first_char = the_string_var.data(); Then cout &first_char.

  • @safatkhan676
    @safatkhan676 Месяц назад +1

    Hey Mike! Referring to 16:52 :
    If s.data() implies some function return from the string class, is that not a temporary r-value to start with?

    • @MikeShah
      @MikeShah  Месяц назад +1

      s.data() is returning the internal pointer to the string class. Since that memory has a location, it is an lvalue (i.e. it's not something temporarily constructed.)

    • @safatkhan676
      @safatkhan676 Месяц назад +1

      @@MikeShah Thanks a lot! I completely misunderstood what s.data() was actually doing. Didn't realise it was literally giving us the pointer to the start of the string. Someone needs to RTFM! Haha! Thanks for all your content.

    • @MikeShah
      @MikeShah  Месяц назад

      @@safatkhan676 cheers! No worries at all

  • @zdspider6778
    @zdspider6778 Год назад +3

    13:46 Could you explain a bit more in detail what "extern "C"" does? Because "extern" is used to tell the compiler that the variable is located in a different translation unit, so it compiles it, then the linker is supposed to look for it _after_ the compiler is done. So what is "C" supposed to be? A string? There's a special rule for it or something?

    • @MikeShah
      @MikeShah  Год назад +1

      The "C" part tells the compiler not to mangle the name and match the C naming convention when loading functions. This is useful when building libraries that may be called from C code.

  • @nematjonabdulloev3568
    @nematjonabdulloev3568 Год назад +3

    Nice explanation.
    How to setup vim for c++ development?

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

      Cheers! My VIM is pretty plain, but this may help for larger longer term projects: ruclips.net/video/IR6pfkqjbw8/видео.html

  • @TheOldRoots
    @TheOldRoots 9 месяцев назад +1

    Hello Mike! Do you have any video that talks about handling very large numbers in c++? Like if I want to store 10000! (which cannot even be stored in an unsigned long long) and use it in some computation for example

    • @MikeShah
      @MikeShah  9 месяцев назад +1

      I don't at this time -- that's a nice idea, and I remember doing this long ago for a homework assignment :)

  • @JaswinderSingh-dz1ui
    @JaswinderSingh-dz1ui Год назад +1

    Hi Sir, Please Explain using namespace std::string_literals or using namespace std::literals

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

      May consider that for a future video -- cheers

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

    Hey mike could we have a session about how to trace the allocation of memory during runtime for every method

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

      Yup, will likely come in my C programming series first then a variation using C++ in this series next.

    • @moatasemelsayed6226
      @moatasemelsayed6226 Год назад +1

      Thank you for your precious effort it is very helpful 😍

  • @ughadunk
    @ughadunk Год назад +1

    Just uniform initialize that string already.

  • @__hannibaal__
    @__hannibaal__ Год назад +1

    If we need Japanese char how to use std::string for jp_char like : std::Jstring . Thanks.

    • @MikeShah
      @MikeShah  Год назад +1

      I believe Japenese characters would be found in UTF-8. Depending on if there is one character or two characters to represent the character set, that might vary whether std::string works with Japanese characters -- and also note your terminal needs to be able to output the UTF-8 encoded characters..