#22 C String Functions | C Programming For Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

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

  • @programizstudios
    @programizstudios  2 ปีที่แล้ว +4

    🚀 Loved the tutorial? Take it further with Programiz PRO!
    Refine your skills, conquer coding fears, and build confidence with interactive lessons, quizzes, and challenges. Strengthen your programming foundation and master C today!
    👉Start Here: bit.ly/c-master

    • @AbhiramDeshpande-fe1vi
      @AbhiramDeshpande-fe1vi ปีที่แล้ว

      #include
      #include
      int main() {
      char text1[50];
      char text2[50];
      printf("enter 1st string :",text1);
      fgets(text1,sizeof(text1),stdin);
      printf("enter 2nd string :",text2);
      fgets(text2,sizeof(text2),stdin);
      strlen(text1)>strlen(text2)?printf(" the larger string is: %s",text1):printf(" the larger string is: %s",text2);
      return 0;
      }

    • @josephnieves8175
      @josephnieves8175 4 หลายเดือนก่อน

      Hi. I'm having problems with a question.
      Read three integers from input and assign the integers to num1, num2, and num3, respectively. Then, output the sum of the three integers, followed by a newline.
      Ex: If the input is 3 4 6, then the output is:
      13
      Ex: If the input is 8 9 5, then the output is:
      22
      Here's the code:
      #include
      int main(void) {
      int num1;
      int num2;
      int num3;
      return 0;
      }

  • @Azizam-j3c
    @Azizam-j3c ปีที่แล้ว +28

    Good video!
    Just a side note, strcmp() doesn't return a random value if the strings are not equal. The function compares the two strings character by character until it finds a difference, and then returns the ASCII value difference between the characters at that position. If the two strings are equal, the function returns 0. If the first character that differs is greater in the first string, the function returns a positive value. If the first character that differs is greater in the second string, the function returns a negative value. Therefore, the value returned by strcmp() is deterministic based on the input strings.

  • @RalphAdrianePDilao
    @RalphAdrianePDilao 2 ปีที่แล้ว +48

    /*Create a Program to compare two strings and print the larger string.*/
    #include
    #include
    int main() {
    char string1[40];
    char string2[40];
    int lengthOfString1;
    int lengthOfString2;
    printf("Please enter string 1: ");
    fgets(string1, sizeof(string1), stdin);
    printf("Please enter string 2: ");
    fgets(string2, sizeof(string1), stdin);
    lengthOfString1 = strlen(string1);
    lengthOfString2 = strlen(string2);
    if(lengthOfString1 > lengthOfString2){
    printf("%s", string1);
    }
    else if(lengthOfString2 > lengthOfString1){
    printf("%s", string2);
    }
    else{
    printf("Both characters has the same length.");
    }
    return 0;
    }

    • @AFCOE
      @AFCOE ปีที่แล้ว

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

      @@AFCOE
      It works perfectly! I Copied it into the Programiz compiler and it works perfectly! 👍👌

    • @akashmathdevru8618
      @akashmathdevru8618 ปีที่แล้ว

      hi i already coded like same but i will get run program output get correct when i put print lenth of string that time size wil be show like 7-8 but i check size of letter is 6-7 what reason what mistake i don't know about this please check paste code.....

    • @ВладимирСоколовский-щ1ы
      @ВладимирСоколовский-щ1ы ปีที่แล้ว

      аа

    • @918903021
      @918903021 8 หลายเดือนก่อน

      @@ВладимирСоколовский-щ1ы Great job!!
      I was stucu, but with the help of your comment you got me unstuck.
      The way you used the "int leng1" helped me a lot to think.
      However what one person is saying with fgets it adds 1 on the length.
      I tried as explained in the video and I still have the same issue.
      Can someone explain?
      #include
      #include
      int main () {
      char str1[40];
      char str2[40];
      printf("Enter string1: ");
      fgets(str1, sizeof(str1), stdin);
      printf("Enter string2: ");
      fgets(str2, sizeof(str2), stdin);
      printf("String1 = %zu
      String2 = %zu
      ", strlen(str1), strlen(str2));
      if(strlen(str1) > strlen(str2)){
      printf("String1 is the lengthier, with %zu chars
      ", strlen(str1));
      }
      else if(strlen(str1) < strlen(str2)) {
      printf("String2 is the lengthier, with %zu chars", strlen(str2));
      }
      else{
      printf("Both are the same length with %zu.", strlen(str1));
      }
      return 0;
      }

  • @pokhto_k_programming
    @pokhto_k_programming 2 ปีที่แล้ว +7

    "Googling things is most the important skill in programing"
    👍💯

  • @onic9623
    @onic9623 ปีที่แล้ว +2

    5:53 why text1 ?
    pls can anyone explain

    • @Onceupon5302
      @Onceupon5302 ปีที่แล้ว

      Same doubt😢

    • @redwings1847
      @redwings1847 23 ชั่วโมงที่ผ่านมา

      What do you mean?
      It's text1 because, the format is,
      strcat(firstString, secondString);
      In the example,
      strcat(text1, text2);
      It's simple, we're connecting the second string to first string, that's why it's text1.

  • @alv1947
    @alv1947 2 ปีที่แล้ว +8

    No word to say how awesome is your work. thank you Programiz team. Simply you rock !!

  • @nahomiperezflores7727
    @nahomiperezflores7727 2 ปีที่แล้ว +4

    I love your videos, I understand them easily.
    Can you explain pointers? Pleaseee

  • @erl2nd
    @erl2nd 2 ปีที่แล้ว +3

    Thank you so much,
    Well done and much appreciated! ☺️
    Quiz answer is: B

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

    Thank you! You are saving me from failing my course!

  • @user-nt4nm4fb3u
    @user-nt4nm4fb3u 11 หลายเดือนก่อน

    As always great explanation. Thank you Programiz for this amazing Tutorial series!!!!!!!!!!!
    I am really enjoying C programming with these tutorial videos!

  • @AmanPandey-of5ok
    @AmanPandey-of5ok หลายเดือนก่อน

    Dididididiididdidididiiiii, Thankkkkuuuuu !! Helped me a lot as a student !! Additionally, The website is awesomeee !!!

  • @jings0nline
    @jings0nline 5 หลายเดือนก่อน

    Loved watching your c programming series, come back with such contents again madam.

  • @naiduyt3350
    @naiduyt3350 2 ปีที่แล้ว +1

    Please do atleast one video daily, can't wait !

  • @nihatdonmzov4166
    @nihatdonmzov4166 2 ปีที่แล้ว +1

    Thank you so much for the video

  • @Sanidu123
    @Sanidu123 6 หลายเดือนก่อน

    Thanks a bunch 🙂

  • @b7sh_b7sh
    @b7sh_b7sh ปีที่แล้ว

    amazing teacher😍

  • @Ech-chatouiMohammed
    @Ech-chatouiMohammed 4 หลายเดือนก่อน

    we appriciate your help

  • @VICTORNAMAWEKES
    @VICTORNAMAWEKES ปีที่แล้ว

    NOW I ALREADY LOVE C 😍

  • @MagaScampini
    @MagaScampini 8 หลายเดือนก่อน +2

    In the strcat example there´s an error, when we use strcat(), the size of the destination string should be large enough to store the resultant string. If not, we will get the segmentation fault error. I don´t understand how her´s is working but if you don´t define the size of destination to be large enough to store the size of the source it´s not gonna work.

    • @hrkhrld
      @hrkhrld 6 หลายเดือนก่อน

      i got segmentation error idk why

  • @governorvantarus
    @governorvantarus 10 หลายเดือนก่อน

    Very well explained, thumbs up 👍

  • @nanimg3512
    @nanimg3512 2 ปีที่แล้ว +3

    🥺🥺🥺 Thank you every much ...🙏

  • @segunomotosho1131
    @segunomotosho1131 ปีที่แล้ว +2

    #include
    #include
    int main() {
    char input1[30];
    char input2[30];
    printf("enter the first value:
    ");
    fgets(input1, sizeof(input1), stdin);
    printf("enter the second value:
    ");
    fgets(input2, sizeof(input2), stdin);
    if (strlen(input1)>strlen(input2))
    {
    printf("%s", input1);
    }
    else if(strlen(input2)>strlen(input1)){
    printf("%s", input2);
    }
    else{
    printf("Both Characters has the same length");
    }
    return 0;
    }

  • @_txt_7398
    @_txt_7398 ปีที่แล้ว

    Thank you so much 🤍

  • @yogithabale
    @yogithabale 6 หลายเดือนก่อน +1

    mam , strcat type function is showing error - segmentation fault

  • @arianas7866
    @arianas7866 2 ปีที่แล้ว +2

    For the programming exercise
    It prints the length of the string to be 1 more than it should be I can't figure out why
    This is my code:
    #include
    int main() {
    char string1[20];
    printf ("Enter string 1:");
    fgets(string1, sizeof(string1), stdin);
    printf ("
    Length: %zu", strlen(string1));
    char string2[20];
    printf ("
    Enter string 2:");
    fgets(string2, sizeof(string2), stdin);
    printf ("
    Length: %zu", strlen(string2));

    if (strlen(string1)> strlen(string2)){
    printf ("
    Sting 1 is bigger");
    }
    else if (strlen(string2) > strlen(string1)){
    printf("
    String 2 is bigger");
    }
    else {
    printf ("
    Same length");
    }
    return 0;
    }

  • @avdeshsingh001
    @avdeshsingh001 ปีที่แล้ว

    Thanks ma'am

  • @kevinolvera8124
    @kevinolvera8124 ปีที่แล้ว

    Good video

  • @betzc9433
    @betzc9433 ปีที่แล้ว

    I was feeling sad because I was having problems, but now everything is making sense!! Thank youuu!

  • @SaiSiddartha-l9o
    @SaiSiddartha-l9o 7 หลายเดือนก่อน

    The answer is option B mam thank you
    😊😊😊

  • @emmanuellegentil9930
    @emmanuellegentil9930 2 ปีที่แล้ว +4

    Hello ma'am
    Nice explanation👍🏽👍🏽
    I've tried to do a program to concatenate 2 string, but this time I ask the user to input 2 strings
    int main(){
    Char name1[50];
    Char name2[50];
    // ask user to input strings
    printf("Enter string 1: ");
    fgets(name1, sizeof(name1), stdin);
    printf("Enter string 2: ");
    fgets(name2, sizeof(name2),stdin);
    //Then I've used strcat to join the 2 strings
    strcat(name1,name2);
    Printf ("%s" , name1);
    return 0;
    }
    But when I compile and run
    When I type the two strings on the compiler, it doesn't concatenate the name1 and name2????
    I gives the output into different lines
    name1
    name2
    Instead of name1 name2
    Can you please tell me what's wrong ??

    • @rajkumar_s31
      @rajkumar_s31 2 ปีที่แล้ว +1

      Use #include header file

    • @akntmzjtj
      @akntmzjtj 2 ปีที่แล้ว

      You probably don't need help for this anymore, but for those that may have the same problem, I believe the reason behind this is because of the way you're handling user input. Of course the goal is to add two strings together, but if the user enters a string that contains whitespace, then it complicates the way we gather those strings. OP knows what he's doing with getting the two strings. However, for some odd reason, using the fgets() function also "gets" the newline (
      ) character and stores it in the char array. Since the user presses Enter to complete their input, it adds that
      character at the end of whatever they typed.
      Luckily enough, the position of this
      character is always at the "strlen()" of the string, minus 1. For example, the string "Hello World", has a length of 11. If it had a newline character, then the length of the string includes that newline character. Therefore, it has a length of 12. If we were to access this character, we would simply type nameOfCharArray[12 - 1]. Then you could probably replace it with the null terminator character \0 to tell the compiler that the string ends there.
      For anyone who's experienced with C, pls correct anything I've said that is wrong, even if everything I said was wrong hahaha.

  • @onomemafuru9496
    @onomemafuru9496 2 ปีที่แล้ว +1

    For the string length calculation of "C programming" is it the white space between C and programming that is counted or the terminal \0?

  • @programizstudios
    @programizstudios  2 ปีที่แล้ว +4

    Q. Which of the following functions is used to join two strings?
    a. strjoin()
    b. strcat()
    c. join()
    d. cat()

  • @Selcuk._._
    @Selcuk._._ 9 หลายเดือนก่อน

    How can we use strlen() at 4:56? strlen() function doesn't return a constant value, and it operates differently depending on compiler time. I've researched this situation, but I still don't understand it. Does anyone know?

    • @Selcuk._._
      @Selcuk._._ 9 หลายเดือนก่อน

      for now i define constant like this
      #define MAX_LENGTH 20
      ...
      char car[] = "Supra Mark IV";
      char bestCar[MAX_LENGTH];
      ...
      and problem solved

  • @laurenzwegler7141
    @laurenzwegler7141 5 หลายเดือนก่อน +1

    //Incredibly secure program, which compares string lenghts:
    //I remembered video #10, are you proud of me? XD
    #include
    #include
    int main()
    {
    printf("Enter string one: ");
    char string1[50];
    gets(string1);
    printf("Enter string two: ");
    char string2[50];
    gets(string2);
    printf("
    The longer string is: ");
    (strlen(string1)) > strlen(string2) ? printf(string1) : printf(string2);
    return 0;
    }

  • @thilagawathis3997
    @thilagawathis3997 2 ปีที่แล้ว

    Make video for storage class mam.. Please

  • @thiagaodavez5465
    @thiagaodavez5465 ปีที่แล้ว

    good dmais

  • @QingqiYang
    @QingqiYang ปีที่แล้ว

    Why does my strcmp function output -1 when it supposed to output -4?

  • @racingfan372
    @racingfan372 2 ปีที่แล้ว +1

    Answer is B. strcat()

  • @learnathingthroughouttheda3464
    @learnathingthroughouttheda3464 2 ปีที่แล้ว

    Why are the other videos private, please allow us to watch them.

  • @hemanthkumarc1828
    @hemanthkumarc1828 ปีที่แล้ว

    #include
    #include
    int main() {
    char length1[45];
    char length2[45];
    printf("enter the character1:");
    fgets(length1,sizeof(length1),stdin);
    printf("enter the character2:");
    fgets(length2,sizeof(length2),stdin);
    int lengthofstring1=strlen(length1);
    int lengthofstring2=strlen(length2);
    if(lengthofstring1>lengthofstring2){
    printf("%s",length1);
    }
    if(lengthofstring1

  • @Peter_1986
    @Peter_1986 ปีที่แล้ว

    It was cute how you used "Pizza" for a food string, and then copied it into "bestFood".

  • @UshmithaYs
    @UshmithaYs 6 ชั่วโมงที่ผ่านมา

    Strlen for c program the length is 12 na how it came 13 can anyone explain plz

  • @mdarifulislamsiam6325
    @mdarifulislamsiam6325 หลายเดือนก่อน

    strcat is not clear why we have used text 1 in printf why not text 2

  • @HoangDo-yv1yw
    @HoangDo-yv1yw ปีที่แล้ว

    👍👍

  • @pawans.3766
    @pawans.3766 2 ปีที่แล้ว

    #include
    #include
    int main()
    {
    char str1[10],str2[10];
    printf("enter a string");
    fgets(str1,sizeof(str1),stdin);
    printf("enter a string");
    fgets(str2,sizeof(str2),stdin);
    int result1 = strlen(str1); int result2 = strlen(str2);
    if(result1>result2){
    printf("str1 is big %s",str1);
    }
    else{
    printf("str2 is big %s",str2);
    }
    return 0;
    }

  • @koxygraphics8706
    @koxygraphics8706 2 ปีที่แล้ว +3

    I’m here because of Alx

  • @errorhostnotfound1165
    @errorhostnotfound1165 2 ปีที่แล้ว

    visual studio 2022 wants me to use strcat_s instead of strcat and asks for a buffer size, but when I give it a buffer size equal to the size of text1 + text2 (which should be 2 more than it needs since I believe sizeof also includes the \0), it says that it overflows the buffer and the buffer is too small

  • @DCSDilshadAhmad
    @DCSDilshadAhmad 2 ปีที่แล้ว

    Option (d) is correct.

  • @yogithabale
    @yogithabale 6 หลายเดือนก่อน

    opt B , strcat()

  • @jordanholmes1366
    @jordanholmes1366 6 หลายเดือนก่อน

    #include
    #include
    int main(/*the answer is B strcat()*/){
    char str1[25], str2[25];
    printf("Type two strings: ");
    fgets(str1, sizeof(str1), stdin);
    fgets(str2, sizeof(str2), stdin);
    (strlen(str1) > strlen(str2)) ? printf("
    %s", str1) : printf("
    %s", str2);
    return 0;
    }

  • @thilagawathis3997
    @thilagawathis3997 2 ปีที่แล้ว

    Say every line meaning mam... It will help to crack interview..

  • @Hypocritecivilization
    @Hypocritecivilization ปีที่แล้ว

    #include
    #include
    int main()
    {
    int length1,length2;
    char text1[50];
    char text2[50];
    printf("enter the text1: ");
    fgets(text1,sizeof(text1),stdin);
    printf("enter the text2: ");
    fgets(text2,sizeof(text2),stdin);
    length1=strlen(text1);
    length2=strlen(text2);
    if(length1>length2)
    {
    printf("%s",text1);
    }
    else
    {
    printf("%s",text2);
    }
    }

  • @stealthy_doctor
    @stealthy_doctor 7 หลายเดือนก่อน

    great video!
    for the quiz to join two together is the strcat() function and this is the program to print the larger input:
    #include
    #include
    int main() {
    // Write C code here
    char word1[20];
    char word2[20];

    printf("Enter the first word: ");
    fgets(word1, sizeof(word1), stdin);//this will get the entier input with spaces


    printf("Enter the second word: ");
    fgets(word2, sizeof(word2), stdin);

    if(strlen(word1)

  • @lynne.5416
    @lynne.5416 2 ปีที่แล้ว +5

    #include
    #include
    int main()
    {
    char string1[100];
    char string2[100];
    printf("Enter first word: ");
    fgets(string1, sizeof(string1), stdin);
    printf("Enter second word: ");
    fgets(string2, sizeof(string2), stdin);
    int Leghth1= strlen(string1);
    int Leghth2= strlen(string2);
    if(Leghth1>Leghth2){
    printf("%s has a larger string", string1);
    }
    else if(Leghth2>Leghth1) { printf("%s has a larger string", string2);
    }
    else { printf("Both have the same leghth"); }
    return 0;
    }

  • @jmarkyt5453
    @jmarkyt5453 2 ปีที่แล้ว +1

    #include
    #include
    #include
    #include
    int main()
    {
    char name[24];
    char name1[24];
    printf("Enter your name:");
    fgets(name, sizeof(name), stdin);
    printf("Enter your friends name:");
    fgets(name1, sizeof(name1), stdin);
    printf("
    The Length of %s is : %zu", name, strlen(name));
    printf("
    And the Length of %s is: %zu

    ", name1, strlen(name1));
    printf("%s:%zu
    ", name, strlen(name));
    printf("%s:%zu", name1, strlen(name1));

    return 0;
    }

  • @oissimouni7726
    @oissimouni7726 ปีที่แล้ว

    #include
    #include
    int main(){
    char text1[20];
    char text2[20];
    printf("Enter the first text: ");
    fgets(text1,sizeof(text1),stdin);
    printf("Enter the second text:");
    fgets(text2,sizeof(text2),stdin);
    int result1=strlen(text1);
    int result2=strlen(text2);
    if (result1>result2){
    printf("%s is the longer text",text1);
    }
    else{
    printf("%s is the longer text",text2);
    }
    return 0;
    }

  • @vintrixtergunot8064
    @vintrixtergunot8064 6 หลายเดือนก่อน

    #include
    #include
    int main() {
    char str1 [20];
    char str2 [20];
    int lengthStr1;
    int lengthStr2;
    printf("String 1: ");
    fgets (str1, sizeof (str1), stdin);
    printf("String 2: ");
    fgets (str2, sizeof (str2), stdin);
    lengthStr1 = strlen (str1);
    lengthStr2 = strlen (str2);
    if (lengthStr1 > lengthStr2){
    printf ("%s", str1);
    }
    else if (lengthStr1 < lengthStr2){
    printf ("%s", str2);
    }

    return 0;
    }

  • @moazriad6582
    @moazriad6582 9 หลายเดือนก่อน +1

    char str9[50];
    char str10[50];
    printf("ENTER NAME:");
    fgets(str9,sizeof(str9),stdin);
    printf("ENTER NAME:");
    fgets(str10,sizeof(str10),stdin);
    int m=strlen(str9);
    printf("%d
    ",m);
    int z=strlen(str10);
    printf("%d
    ",z);
    if(m>z)
    printf("%s",str9);
    if(z>m)
    printf("%s",str10);

  • @bbek300
    @bbek300 9 หลายเดือนก่อน

    #include
    #include
    int main() {
    char word1[20];
    char word2[20];
    printf("Enter word1: ");
    fgets(word1, sizeof(word1), stdin);
    printf("Enter word2: ");
    fgets(word2, sizeof(word2), stdin);
    int L1 = strlen(word1);
    int L2 = strlen(word2);
    if(L1 > L2){
    printf("%s",word1);
    }
    else if(L2 > L1){
    printf("%s",word2);
    }
    else{
    printf("Both are equal");
    }
    return 0;
    }

  • @JeongWoonKim-i4j
    @JeongWoonKim-i4j ปีที่แล้ว

    #include
    #include
    int main() {
    char str1[50];
    char str2[50];
    printf("Enter the fisrt string: ");
    fgets(str1, sizeof(str1), stdin);
    printf("Enter the second string: ");
    fgets(str2, sizeof(str2), stdin);
    if(strlen(str1) > strlen(str2)) {
    printf("%s", str1);
    }
    else if(strlen(str1) < strlen(str2)) {
    printf("%s", str2);
    }
    else {
    printf("None");
    }
    return 0;
    }

  • @light-warrior
    @light-warrior 11 หลายเดือนก่อน

    #include
    #include
    int main() {
    char string[20];
    printf("
    Enter your name: ");
    fgets(string, sizeof (string), stdin);
    printf("
    Lenghth: %zu", strlen(string));
    char string1[20];
    printf("
    Enter your name: ");
    fgets(string1, sizeof (string1), stdin);
    printf("
    Lenghth: %zu", strlen(string1));
    if (string > string1) {
    printf("
    Longer name: %s", string);
    } else {
    printf("
    Longer name: %s", string1);
    }
    return 0;
    }
    B is the correct option.

  • @PraveenPraveen-us3rp
    @PraveenPraveen-us3rp ปีที่แล้ว

    Options B

  • @Azizam-j3c
    @Azizam-j3c ปีที่แล้ว

    //Solution:
    #include
    #include
    int main() {
    char str1[50];
    char str2[50];
    printf("Enter the first String: ");
    fgets(str1, 50, stdin);
    printf("Enter the second String: ");
    fgets(str2, 50, stdin);
    char result[(strlen(str1) > strlen(str2)) ? strlen(str1) : strlen(str2)];
    (strlen(str1) > strlen(str2)) ? strcpy(result, str1) : strcpy(result, str2);
    printf("%s", result);
    return 0;
    }

  • @streamvision145
    @streamvision145 8 หลายเดือนก่อน +1

    #include
    #include
    int main() {
    char str1[30];
    char str2[30];
    printf("-----------String Comparison-----------

    ");
    printf("Enter string 1: ");
    fgets(str1,sizeof(str1),stdin);
    printf("Enter string 2: ");
    fgets(str2,sizeof(str2),stdin);
    int diff = strlen(str1) - strlen(str2);
    if(diff > 0){
    printf("
    The larger string is %s.",str1);
    } else if(diff < 0){
    printf("
    The larger string is %s.",str2);
    }else{
    printf("
    Both are of the same length.");
    }
    return 0;
    }

  • @diecastlover4531
    @diecastlover4531 ปีที่แล้ว

    Strlen()
    Strcpy(to,from)
    Strcat(text1,text2)
    Strcmp(text1,text2)
    Fgets(name,sizeof(name),stdin)

  • @mohamedhajith965
    @mohamedhajith965 ปีที่แล้ว

    when I run the "strcat" function, "segmentation fault" this out put was shown
    #include
    #include
    int main(){
    char name1[]="hi";
    char name2[]="how are you";
    strcat(name1,name2);
    printf("%s",name1);
    return 0;
    }
    this is my code

  • @azhaguramkumar2988
    @azhaguramkumar2988 12 วันที่ผ่านมา

    Str cat is correct

  • @chinenyeumeaku9262
    @chinenyeumeaku9262 ปีที่แล้ว

    #include
    #include
    int main() {
    char text1[15];
    char text2[15];
    int lenght1;
    int lenght2;
    printf("Enter text1: ");
    fgets(text1, sizeof(text1), stdin);
    printf("Enter text2: ");
    fgets(text2, sizeof(text2), stdin);
    lenght1 = strlen(text1);
    lenght2 = strlen(text2);
    if (lenght1 > lenght2)
    {
    printf("%s", text1);
    }
    else if (lenght2 == lenght1)
    {
    printf("the same lenght");
    }
    else
    printf("%s", text2);
    return 0;
    }

  • @mokka_comedy
    @mokka_comedy 8 หลายเดือนก่อน

    Now string functions are not working in the programiz complier....................

  • @formodapk
    @formodapk 3 หลายเดือนก่อน

    #programiz

  • @Isasseguya
    @Isasseguya ปีที่แล้ว

    #include
    #include
    #include
    int main() {
    char txt1[50];
    char txt2[50];
    printf("Enter 2 strings: ");
    fgets(txt1, sizeof(txt1), stdin);
    fgets(txt2, sizeof(txt2), stdin);
    strlen(txt1);
    strlen(txt2);
    if(strlen(txt1)>strlen(txt2)){
    printf("%s",txt1);
    }
    else{
    printf("%s",txt2);
    }
    return 0;
    }

  • @Clog17
    @Clog17 7 หลายเดือนก่อน

    #include
    #include
    #define size 100
    int main()
    {
    char str[size];
    char str2[size];
    printf("please enter a name: ");
    fgets(str, sizeof(str),stdin);
    printf("please enter a surname: ");
    fgets(str2, sizeof(str2),stdin);
    if (strlen(str) > strlen(str2)){
    printf ("%s", str);
    }
    else{
    printf("%s", str2);
    }
    return 0;
    }

  • @albertamenyah3019
    @albertamenyah3019 ปีที่แล้ว

    The answer is B. strcat()

  • @nagashreenb4763
    @nagashreenb4763 2 หลายเดือนก่อน

    void main()
    {
    char str1[20],str2[20];
    printf("Enter first str1:");
    fgets(str1,sizeof(str1),stdin);
    printf("Enter the second Str2:");
    fgets(str2,sizeof(str2),stdin);
    int sizeofstr1=strlen(str1);
    printf("Size of the str1 is :%d
    ",sizeofstr1);
    int sizeofstr2=strlen(str2);
    printf("Size of the str2 is :%d
    ",sizeofstr2);

    if(sizeofstr1>sizeofstr2)
    printf("the largest str is str1:%s
    ",str1);
    else if(sizeofstr1

  • @fighterboy6577
    @fighterboy6577 2 ปีที่แล้ว +3

    b

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

    #include
    #include
    int main() {
    // Create a program to compare two strings and prints the larger strings.
    // * Get two strings input from the user using fgets().
    // * compare the length of both strings using strlen().
    // * Print the larger string.
    char name1[20];
    char name2[20];
    printf("Enter first full name: ");
    fgets(name1, sizeof(name1), stdin);
    printf("Enter second full name: ");
    fgets(name2, sizeof(name2), stdin);
    if (strlen(name1) < strlen(name2))
    {
    printf("%s", name2);
    }
    else {
    printf("%s", name1);
    }
    }

  • @anesp.a913
    @anesp.a913 2 ปีที่แล้ว

    strcat(first string,second string);

  • @qarikhalidwaheed1643
    @qarikhalidwaheed1643 ปีที่แล้ว

    The answer is C
    By the way all of the answers are the letter C because we are working in C programming language

  • @bullshit485
    @bullshit485 2 หลายเดือนก่อน

    The Answer is B. strcat().

  • @shriyanshgupta9951
    @shriyanshgupta9951 2 ปีที่แล้ว +1

    // Online C compiler to run C program online
    #include
    #include
    int main() {
    char text1[100], text2[100];
    printf("Enter String 1 : ");
    fgets(text1, sizeof(text1), stdin);
    printf("Enter String 2 : ");
    fgets(text2, sizeof(text2), stdin);
    int len1 = strlen(text1);
    int len2 = strlen(text2);
    if (len1 > len2)
    printf("%s is Greater", text1);
    else if (len2 > len1)
    printf("%s is Greater", text2);
    else
    printf("Both are same");
    return 0;
    }

  • @sibonginkosiphiri6269
    @sibonginkosiphiri6269 ปีที่แล้ว

    Answer is B

  • @keshavdixit08
    @keshavdixit08 2 ปีที่แล้ว

    Answer : B

  • @sandeepvarma8453
    @sandeepvarma8453 9 หลายเดือนก่อน

    b.strcat( )

  • @mofemoluwasiogunrinde4891
    @mofemoluwasiogunrinde4891 2 ปีที่แล้ว

    B. strcat()

  • @herkesebolsanshahaha4229
    @herkesebolsanshahaha4229 ปีที่แล้ว

    İt is Zero not Cero

  • @mohammednoorullahkhan
    @mohammednoorullahkhan ปีที่แล้ว

    i love you padma manandhar

  • @WSW254
    @WSW254 ปีที่แล้ว

    strat()

  • @1NazareeM618
    @1NazareeM618 ปีที่แล้ว

  • @amirfoo6565
    @amirfoo6565 2 ปีที่แล้ว

    B

  • @Profession_marketting
    @Profession_marketting ปีที่แล้ว

    Wo

  • @chrisoigo8598
    @chrisoigo8598 2 ปีที่แล้ว +1

    #include
    #include
    int main()
    {
    char game[20];
    char match[20];
    int length_of_game;
    int length_of_match;
    printf("ENTER THE GAME: ");
    fgets(game, sizeof(game), stdin);
    printf("ENTER THE MATCH : ");
    fgets(match, sizeof(match), stdin);
    length_of_game = strlen(game);
    length_of_match = strlen(match);
    if(length_of_game> length_of_match){
    printf("%s", game);
    }
    if(length_of_game==length_of_match){
    printf("strings have the same length");
    }
    else{
    printf("%s", match);
    }
    return 0;
    }

  • @chhotujogiya1248
    @chhotujogiya1248 8 วันที่ผ่านมา

    Anyone from KBP college Vashi mumbai 😅😅

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

    /*
    Create a program to compare two strings and
    print the larger strings.
    * Get two string input from the user using
    fgets()
    * Compare the length of both the strings using
    strlen()
    * Print the larger string
    */
    #include
    #include
    char compare(char firstWord[100], char secondWord[100]);
    int main(){
    char stringInput1[100];
    char stringInput2[100];

    printf("Enter a first word: ");
    fgets(stringInput1, sizeof stringInput1, stdin);
    printf("Enter a second word: ");
    fgets(stringInput2, sizeof stringInput2, stdin);

    compare(stringInput1, stringInput2);
    return 0;
    }
    char compare(char firstWord[100], char secondWord[100]){
    int lengthText1 = strlen(firstWord);
    int lengthText2 = strlen(secondWord);
    if (lengthText1 > lengthText2){
    return printf("%s ", firstWord);
    }
    else if (lengthText1 < lengthText2){
    return printf("%s ", secondWord);
    }
    else{
    return printf("%s", strcat(firstWord, secondWord) );
    }

    }

  • @muhammadrizobegijonov4002
    @muhammadrizobegijonov4002 8 หลายเดือนก่อน

    0

  • @Akhil-hd8qe
    @Akhil-hd8qe 8 หลายเดือนก่อน

    Akka you are so beautiful

  • @xxxegster6527
    @xxxegster6527 ปีที่แล้ว

    quiz anwer :b

  • @missserwaa_
    @missserwaa_ ปีที่แล้ว

    #include
    #include
    int main()
    {
    char name[30];
    char hometown[30];
    printf("Enter your name: ");
    fgets(name, sizeof(name), stdin);
    printf("Your name is: %s", name);
    printf("Enter hometown: ");
    fgets(hometown, sizeof(hometown), stdin);
    printf("Your hometown is: %s", hometown);
    printf("
    length of name: %zu", strlen(name));
    printf("
    length of hometown: %zu", strlen(hometown));
    if(strlen(name) > strlen(hometown)) {
    printf("
    %s", name);
    } else {
    printf("
    %s", hometown);
    }
    return 0;
    }

  • @freehug071
    @freehug071 2 ปีที่แล้ว +1

    #include
    #include
    int main(void)
    {
    char text1[45];
    char text2[45];
    printf("please Enter your name:");
    fgets(text1, sizeof(text2), stdin);
    printf("%s", text1);
    printf("please Enter your school:");
    fgets(text2, sizeof(text2), stdin);
    printf("%s
    ", text2);
    if(strlen(text1) > strlen(text2)){
    printf("leng of text1 is %zu", strlen(text1));
    }
    if(strlen(text2) > strlen(text1)){
    printf("leng of text2 is %zu", strlen(text2));
    }
    else{
    printf("the leng of two string is equal");
    }
    return 0;
    }

  • @aritradey7189
    @aritradey7189 2 ปีที่แล้ว

    // Task programme 😀😀
    #include
    #define n 100
    int main(){
    char str1[n];
    char str2[n];
    printf("enter the first string:");
    gets(str1);
    printf("enter the second string:");
    gets(str2);
    int result1=strlen(str1);
    int result2=strlen(str2);
    printf("%d
    ",result1);
    printf("%d
    ",result2);
    if(result1>result2)
    {
    printf(" Got it str1 is the longer string.");
    }
    else{
    printf(" Got it str2 is the longer string.");
    }
    }

  • @hunter9544
    @hunter9544 9 หลายเดือนก่อน

    // Online C compiler to run C program online
    #include
    #include
    int main() {
    // Write C code here
    char text1[100];
    char text2[100];
    int lengthoftext1;
    int lengthoftext2;
    printf("Enter text 1: ");
    fgets(text1, sizeof(text1), stdin);
    { printf("Enter text 2: ");
    fgets(text2, sizeof(text2),stdin);
    lengthoftext1=strlen(text1);
    lengthoftext2=strlen(text2);
    if (lengthoftext1 > lengthoftext2)
    { printf("%s", text1); }
    else if (lengthoftext2 > lengthoftext1) {
    printf("%s", text2);
    }
    else
    printf("Both: %s and: %s are the same length", text1, text2);
    }


    return 0;
    }
    Arise