+ 2

YouTube link finder using C

Question: 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 ------------------- My program: #include <stdio.h> #include <string.h> int main() { char a[100]; char f[100]; int l = 0, i, j = 0; scanf("%s", a); for(i = 0; a[i] != '\0'; i++) { l++; } for(i = l; i > l - 12; i--) { f[j++] = a[i]; } for(i = 0; f[i] != '\0'; i++) { printf("%c", f[i]); } return 0; } I'm getting output as 'No output', what's wrong here?

7th Feb 2022, 5:13 PM
GURURAJ KL
GURURAJ KL - avatar
2 Réponses
+ 2
#include <stdio.h> #include <string.h> int main() { char a[100]; char f[12]; int l = 0, i, j = 0; scanf("%s", a); for(i = 0; a[i] != '\0'; i++) { l++; } for(i = l; i > l - 12; i--) { f[j] = a[i]; j++; } for(i = 11; i > 0; i--) { printf("%c", f[i]); } return 0; } #This changes worked for me :)
7th Feb 2022, 5:28 PM
GURURAJ KL
GURURAJ KL - avatar