Please help me in this code... 3 taste case are running successfully but remaining two are not 😐😐😐 ... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Please help me in this code... 3 taste case are running successfully but remaining two are not 😐😐😐 ...

Task:  Create a program that parses through a link, extracts and outputs the YouTube video ID. Input Format: A string containing the URL to a YouTube video. The format of the string can be in "https://www.youtube.com/watch?v=kbxkq_w51PM" or the shortened "https://youtu.be/KMBBjzp5hdc" format. Output Format: A string containing the extracted YouTube video id. Sample Input: https://www.youtube.com/watch?v=RRW2aUSw5vU Sample Output: RRW2aUSw5vU Here is my attempt :- #include <stdio.h> #include <string.h> int main() { char str[200]; int i,j; int count=0; scanf("%s",str); for(i=0;i<strlen(str);i++) { if(str[i]=='=') { i++; for(j=i;j<strlen(str);j++) { printf ("%c",str[j]); } break; } else if(str[i]>=65 && str[i] <= 91) { for(j=i;j<strlen(str);j++) { printf ("%c",str[j]); } break; } } return 0; }

21st Jan 2022, 5:38 PM
Neeraj Kumar
Neeraj Kumar - avatar
5 Answers
+ 1
This can be done lot ways.. I did it in java and printed text after the characters = or / ( found it's positions in reverse way) One way you can is if, first method fails then print text after from / character. (Out of for loop).. Try think, again.. You may find more easy way... Or by my way, from reverse, copy characters to an array until = or / encounters and print array in reverse... Hope it helps. . .
21st Jan 2022, 6:25 PM
Jayakrishna 🇮🇳
+ 1
I think, what if link of short form not starting with a capital letter..? Fails then
21st Jan 2022, 5:49 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 yeah I also thought this btt i haven't any more idea how this code will be work for this output... Can u solve this problem?
21st Jan 2022, 6:15 PM
Neeraj Kumar
Neeraj Kumar - avatar
+ 1
Yeah this reverse way is absolutely working, nd definitely I'll think more ways to do it... thank you so much Jayakrishna🇮🇳 .
22nd Jan 2022, 3:24 AM
Neeraj Kumar
Neeraj Kumar - avatar
+ 1
You're welcome...
22nd Jan 2022, 8:19 AM
Jayakrishna 🇮🇳