#22 C String Functions | C Programming For Beginners

  Рет қаралды 87,780

Programiz

Programiz

Күн бұрын

Пікірлер: 150
@programizstudios
@programizstudios 2 жыл бұрын
Finding C programming hard? We’ve got you! 🚀Get 60% off on Programiz PRO Lifetime Plan this Black Friday-pay once for skills that last forever. Don’t miss out, it’s a limited-time offer! 👉Grab your discount now: bit.ly/blkfriday-24-yt
@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 3 ай бұрын
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 Жыл бұрын
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 жыл бұрын
/*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 Жыл бұрын
@@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 7 ай бұрын
@@ВладимирСоколовский-щ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 жыл бұрын
"Googling things is most the important skill in programing" 👍💯
@erl2nd
@erl2nd 2 жыл бұрын
Thank you so much, Well done and much appreciated! ☺️ Quiz answer is: B
@eszterannaimre711
@eszterannaimre711 Жыл бұрын
Thank you! You are saving me from failing my course!
@segunomotosho1131
@segunomotosho1131 Жыл бұрын
#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; }
@jings0nline
@jings0nline 4 ай бұрын
Loved watching your c programming series, come back with such contents again madam.
@alv1947
@alv1947 2 жыл бұрын
No word to say how awesome is your work. thank you Programiz team. Simply you rock !!
@MagaScampini
@MagaScampini 7 ай бұрын
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 5 ай бұрын
i got segmentation error idk why
@arianas7866
@arianas7866 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; }
@user-nt4nm4fb3u
@user-nt4nm4fb3u 10 ай бұрын
As always great explanation. Thank you Programiz for this amazing Tutorial series!!!!!!!!!!! I am really enjoying C programming with these tutorial videos!
@nahomiperezflores7727
@nahomiperezflores7727 2 жыл бұрын
I love your videos, I understand them easily. Can you explain pointers? Pleaseee
@jordanholmes1366
@jordanholmes1366 5 ай бұрын
#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; }
@stealthy_doctor
@stealthy_doctor 5 ай бұрын
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)
@laurenzwegler7141
@laurenzwegler7141 4 ай бұрын
//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; }
@naiduyt3350
@naiduyt3350 2 жыл бұрын
Please do atleast one video daily, can't wait !
@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
@betzc9433
@betzc9433 Жыл бұрын
I was feeling sad because I was having problems, but now everything is making sense!! Thank youuu!
@ВладимирСоколовский-щ1ы
@ВладимирСоколовский-щ1ы Жыл бұрын
Dear friend. Visit channel SolveMy ProgrammingTask. Thank you.
@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; }
@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); } }
@onic9623
@onic9623 Жыл бұрын
5:53 why text1 ? pls can anyone explain
@Onceupon5302
@Onceupon5302 Жыл бұрын
Same doubt😢
@lynne.5416
@lynne.5416 2 жыл бұрын
#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; }
@light-warrior
@light-warrior 10 ай бұрын
#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.
@moazriad6582
@moazriad6582 7 ай бұрын
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);
@jmarkyt5453
@jmarkyt5453 Жыл бұрын
#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; }
@VICTORNAMAWEKES
@VICTORNAMAWEKES Жыл бұрын
NOW I ALREADY LOVE C 😍
@SaiSiddartha-l9o
@SaiSiddartha-l9o 6 ай бұрын
The answer is option B mam thank you 😊😊😊
@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; }
@diecastlover4531
@diecastlover4531 Жыл бұрын
Strlen() Strcpy(to,from) Strcat(text1,text2) Strcmp(text1,text2) Fgets(name,sizeof(name),stdin)
@governorvantarus
@governorvantarus 8 ай бұрын
Very well explained, thumbs up 👍
@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; }
@nihatdonmzov4166
@nihatdonmzov4166 Жыл бұрын
Thank you so much for the video
@programizstudios
@programizstudios Жыл бұрын
You are so welcome!
@vintrixtergunot8064
@vintrixtergunot8064 5 ай бұрын
#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; }
@bbek300
@bbek300 8 ай бұрын
#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; }
@racingfan372
@racingfan372 Жыл бұрын
Answer is B. strcat()
@Ech-chatouiMohammed
@Ech-chatouiMohammed 2 ай бұрын
we appriciate your help
@nanimg3512
@nanimg3512 2 жыл бұрын
🥺🥺🥺 Thank you every much ...🙏
@emmanuellegentil9930
@emmanuellegentil9930 2 жыл бұрын
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 жыл бұрын
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.
@yogithabale
@yogithabale 4 ай бұрын
mam , strcat type function is showing error - segmentation fault
@programizstudios
@programizstudios 2 жыл бұрын
Q. Which of the following functions is used to join two strings? a. strjoin() b. strcat() c. join() d. cat()
@naiduyt3350
@naiduyt3350 2 жыл бұрын
B
@rickzalman4136
@rickzalman4136 2 жыл бұрын
strcat() function adds two c-strings together.
@abhishekreddy354
@abhishekreddy354 2 жыл бұрын
B=strcat()
@saketkumar4972
@saketkumar4972 2 жыл бұрын
cat
@lordhexler29
@lordhexler29 2 жыл бұрын
b. strcat
@Isasseguya
@Isasseguya 11 ай бұрын
#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; }
@AkunemeMighty
@AkunemeMighty Жыл бұрын
#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); } }
@thilagawathis3997
@thilagawathis3997 2 жыл бұрын
Say every line meaning mam... It will help to crack interview..
@onomemafuru9496
@onomemafuru9496 2 жыл бұрын
For the string length calculation of "C programming" is it the white space between C and programming that is counted or the terminal \0?
@AbhiramDeshpande-fe1vi
@AbhiramDeshpande-fe1vi Жыл бұрын
its the space
@AbhiramDeshpande-fe1vi
@AbhiramDeshpande-fe1vi Жыл бұрын
I too got a doubt but later i tested it ....
@DCSDilshadAhmad
@DCSDilshadAhmad Жыл бұрын
Option (d) is correct.
@b7sh_b7sh
@b7sh_b7sh Жыл бұрын
amazing teacher😍
@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; }
@axlelibrium9059
@axlelibrium9059 Жыл бұрын
this is my code: #include #include int main(){ char text1[100]; char text2[100]; printf("Enter first string: "); gets(text1); printf(" Enter second string: "); gets(text2); if(strlen(text1) > strlen(text2)){ printf(" First string is longer which is: %s",text1); }else printf(" Second string is longer which is: %s",text2); return 0; }
@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; }
@Sanidu123
@Sanidu123 4 ай бұрын
Thanks a bunch 🙂
@streamvision145
@streamvision145 6 ай бұрын
#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; }
@Clog17
@Clog17 6 ай бұрын
#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; }
@koxygraphics8706
@koxygraphics8706 2 жыл бұрын
I’m here because of Alx
@thilagawathis3997
@thilagawathis3997 2 жыл бұрын
Make video for storage class mam.. Please
@Peter_1986
@Peter_1986 Жыл бұрын
It was cute how you used "Pizza" for a food string, and then copied it into "bestFood".
@_txt_7398
@_txt_7398 Жыл бұрын
Thank you so much 🤍
@avdeshsingh001
@avdeshsingh001 Жыл бұрын
Thanks ma'am
@nagashreenb4763
@nagashreenb4763 18 күн бұрын
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
@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
@inhhuynhcong5009
@inhhuynhcong5009 Жыл бұрын
I think c programmiz gets a bug so you cannot run this code
@mohamedhajith965
@mohamedhajith965 Жыл бұрын
Ok thank you
@kevinolvera8124
@kevinolvera8124 Жыл бұрын
Good video
@yogithabale
@yogithabale 4 ай бұрын
opt B , strcat()
@bullshit485
@bullshit485 25 күн бұрын
The Answer is B. strcat().
@formodapk
@formodapk Ай бұрын
#programiz
@errorhostnotfound1165
@errorhostnotfound1165 Жыл бұрын
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
@learnathingthroughouttheda3464
@learnathingthroughouttheda3464 2 жыл бұрын
Why are the other videos private, please allow us to watch them.
@albertamenyah3019
@albertamenyah3019 Жыл бұрын
The answer is B. strcat()
@mdarifulislamsiam6325
@mdarifulislamsiam6325 6 күн бұрын
strcat is not clear why we have used text 1 in printf why not text 2
@QingqiYang
@QingqiYang Жыл бұрын
Why does my strcmp function output -1 when it supposed to output -4?
@Selcuk._._
@Selcuk._._ 7 ай бұрын
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._._ 7 ай бұрын
for now i define constant like this #define MAX_LENGTH 20 ... char car[] = "Supra Mark IV"; char bestCar[MAX_LENGTH]; ... and problem solved
@PraveenPraveen-us3rp
@PraveenPraveen-us3rp Жыл бұрын
Options B
@thiagaodavez5465
@thiagaodavez5465 Жыл бұрын
good dmais
@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
@fighterboy6577
@fighterboy6577 2 жыл бұрын
b
@shriyanshgupta9951
@shriyanshgupta9951 2 жыл бұрын
// 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; }
@anesp.a913
@anesp.a913 2 жыл бұрын
strcat(first string,second string);
@HoangDo-yv1yw
@HoangDo-yv1yw Жыл бұрын
👍👍
@keshavdixit08
@keshavdixit08 2 жыл бұрын
Answer : B
@sibonginkosiphiri6269
@sibonginkosiphiri6269 Жыл бұрын
Answer is B
@freehug071
@freehug071 Жыл бұрын
#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; }
@mokka_comedy
@mokka_comedy 6 ай бұрын
Now string functions are not working in the programiz complier....................
@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; }
@bryanbalantes6486
@bryanbalantes6486 Жыл бұрын
/* 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) ); } }
@sandeepvarma8453
@sandeepvarma8453 7 ай бұрын
b.strcat( )
@mofemoluwasiogunrinde4891
@mofemoluwasiogunrinde4891 2 жыл бұрын
B. strcat()
@mohammednoorullahkhan
@mohammednoorullahkhan Жыл бұрын
i love you padma manandhar
@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."); } }
@amirfoo6565
@amirfoo6565 2 жыл бұрын
B
@chrisoigo8598
@chrisoigo8598 2 жыл бұрын
#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; }
@herkesebolsanshahaha4229
@herkesebolsanshahaha4229 Жыл бұрын
İt is Zero not Cero
@Amirak254
@Amirak254 Жыл бұрын
strat()
@Profession_marketting
@Profession_marketting Жыл бұрын
Wo
@muhammadrizobegijonov4002
@muhammadrizobegijonov4002 7 ай бұрын
0
@xxxegster6527
@xxxegster6527 Жыл бұрын
quiz anwer :b
@Akhil-hd8qe
@Akhil-hd8qe 6 ай бұрын
Akka you are so beautiful
@hunter9544
@hunter9544 7 ай бұрын
// 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
@anjeepshrestha6177
@anjeepshrestha6177 2 жыл бұрын
#include #include #include int main() { char a[20]="Anjeep Shrestha"; char b[30]=" is a good boy."; // for finding the length printf("The length of string a is %zu",strlen(a)); // for string copy char c[strlen(a)]; strcpy(c,a); printf(" %s",c); // for string concatenation strcat(a,b); printf(" The concatenated string is %s",a); // for string compare char d[10]="anjeep"; char e[10]="anjeep"; char f[10]="shrestha"; printf(" The value for d and e compare is %d",strcmp(d,e)); printf(" The value for e and f compare is %d",strcmp(e,f)); printf(" The value for f and e compare is %d",strcmp(f,e)); }
@daireosullivan1193
@daireosullivan1193 8 ай бұрын
#include #include #include #include #include int main() { char text1[200]; char text2[200]; printf("Enter a text: "); fgets(text1, sizeof(text1), stdin); printf("Enter another text: "); fgets(text2, sizeof(text2), stdin); if (strlen(text1) > strlen(text2)) { printf("%s", text1); } else if (strlen(text1) == (strlen(text2))) { printf("Equal Strings"); } else { printf("%s", text2); } return 0; }
@onic9623
@onic9623 Жыл бұрын
Option B : strcat() ----------------------------------------------------------------------------- #include #include int main() { char text1[100], text2[100]; while (1) { printf("Enter A Name : "); fgets(text1, sizeof(text1), stdin); printf("Enter Another Name : "); fgets(text2, sizeof(text2), stdin); if (strlen(text1) > strlen(text2)) { printf("%s", text1); } else if (strlen(text1) < strlen(text2)) { printf("%s", text2); } else { printf("Both Are Of Equal Lenghth"); } } return 0; }
@TheHeraldOfSpring
@TheHeraldOfSpring 3 ай бұрын
#include #include int main(){ char userString1[40], userString2[40]; printf("Enter your first statement: "); fgets(userString1, 40, stdin); printf("Enter your second statement: "); fgets(userString2, 40, stdin); int strSize1 = strlen(userString1); int strSize2 = strlen(userString2); printf(" Now we will print the biggest statement... "); if(strSize1 > strSize2){ printf("The winner statement is: %s", userString1); } else if(strSize2 > strSize1){ printf("The winner statement is: %s", userString2); } else{ printf("The friendship has won: %s %s", userString1, userString2); } return 0; }
#23 C Pointers | C Programming For Beginners
11:01
Programiz
Рет қаралды 148 М.
#21 C Strings | C Programming For Beginners
10:13
Programiz
Рет қаралды 149 М.
Thank you Santa
00:13
Nadir Show
Рет қаралды 48 МЛН
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 37 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 27 МЛН
#15  C Functions | C Programming for Beginners
16:57
Programiz
Рет қаралды 232 М.
C string functions 🔠
5:03
Bro Code
Рет қаралды 71 М.
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,3 МЛН
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 7 М.
48 - STRING HANDLING FUNCTIONS - C PROGRAMMING
35:19
Sundeep Saradhi Kanthety
Рет қаралды 129 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
why do header files even exist?
10:53
Low Level
Рет қаралды 433 М.
you will never ask about pointers again after watching this video
8:03
#19 C Arrays | C Programming For Beginners
13:04
Programiz
Рет қаралды 280 М.
Thank you Santa
00:13
Nadir Show
Рет қаралды 48 МЛН