String Functions In C & string.h Library: C Tutorial In Hindi #35

preview_player
Показать описание
In this series of C programming tutorial videos, I have explained you everything you need to know about C language. I hope you are enjoying this C course in Hindi.

Best Hindi Videos For Learning Programming:

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

Sir,
This is the answer of the quiz

#include <stdio.h>
#include <string.h>

int main()
{
char s1[20];
char s2[20];
char s3[30] = " is a frind of ";

printf("Enter the name of first friend\n");
gets(s1);

printf("Enter the name of second friend\n");
gets(s2);

puts(strcat(s1, (strcat(s3, s2))));

return 0;
}

fullygaming
Автор

Sir your channel has helped me understand much better than Apna college because you explain all of the basics which a beginner could face difficulty in understanding.I am glad I found your channel

_Ojasmahajan
Автор

Two things to keep in mind would be strrev() has been removed from gcc and gets() has been removed from c11, so write your own code to reverse a string either using loops or recursion as per your choice, using gets() might give a warning so we can use the following to take a string input from the user until a new-line element is encountered :-
i) scanf("%[^\n]%*c", str);
ii) scanf("%[^\n]s", str);
where [] is the scanset character.

hope this helps.
btw the content is great.

arkabhattacharya
Автор

17:29
/*
Allow user to enter two strings and then concatenate them by saying that str1 is a friend of str2
*/
#include<stdio.h>
#include<string.h>
int main()
{
char str1[100];
char str2[100];
char str3[]=" is a friend of ";
printf("Enter the name: ");
gets(str1);
printf("Enter the name: ");
gets(str2);
puts(strcat(str1, strcat(str3, str2)));
return 0;
}

dassomnath-nnn
Автор

//Input two strings and concatenate them

#include<stdio.h>
#include<string.h>
void main()
{
char str1[10], str2[10];
char str3[]=" is a friend of ", str4[10];
printf("Enter the first name:\n");
gets(str1);
printf("Now, enter the second name:\n");
gets(str2);
strcpy(str4, (strcat(str1, str3)));
puts(strcat(str4, str2));

}

adityarajsingh
Автор

#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
char s1[20];
char s2[20];
char s3[20];


printf("Enter your name");
scanf("%s", &s1);
strcat(s1, " is a friend of ");

printf("Enter Seconds name");
scanf("%s", s2);
strcpy(s3, strcat(s1, s2));
puts(s3);

}

RDSinghofficial
Автор

/*
author : Bishal jaiswal
purpose : practice
Quiz from : CodeWithHarry - Harry a great teacher
*/

#include <stdio.h>
#include <string.h> // module needed for this operation

int main()
{
char first[20]; // variable to store the name of the first friend
char second[20]; // variable for storing the name of the second friend
char var[] = " is a friend of "; // putting a string manually

// Operation Specific Variables
char string[50];
char finalText[60];

printf("Enter a name\n> ");
gets(first); // taking the name of first friend

printf("Enter the another name\n> ");
gets(second); // taking the name of second friend

strcpy(string, (strcat(first, var))); /* concatinating the first friend with variable named "var" and storing it in a variable
named "string" */

strcpy(finalText, (strcat(string, second))); /* concatinating variable named "string" and "secod" and storing it in a variable
named "finalText" */

puts(finalText); // displaying the result

return 0;
}

sakalagamingyt
Автор

Awesome....

The Code :

#include <stdio.h>
#include <string.h>

int main()
{
char s1[50];
char s2[50];
char s3[] = "is friend of";

printf("Enter the two string names :\n");
gets(s1);
gets(s2);

printf("%s is friend of %s\n", s1, s2);

puts(strcat(s1, strcat(s1, s2)));

return 0;
}

parthlimbasiya
Автор

oops did it by mistake
#include<stdio.h>
#include<string.h>
int main()
{
char s1[20], s2[20], s3[]=" is a friend of ";
printf("Enter the name of your friend 1=");
gets(s1);
printf("Enter the name of your friend 2=");
gets(s2);
printf("\nby easy method\n");
printf("%s is a friend of %s\n", s1, s2);
printf("by cat method\n");
printf("%s", strcat(strcat(s1, s3), s2));
return 0;
}

saitamalightyagami
Автор

Sir Answer to this question is very simple beause of your lectuures:
#include <stdio.h>
#include <string.h>

int main()
{
char s1[20];
char s2[20];
printf("Enter name of 1st person:\n");
gets(s1);
printf("Enter name of 2nd person:\n");
gets(s2);

char s3[]=" is a friend of ";

printf("%s", strcat(s1, strcat(s3, s2)));

return 0;
}

mrhuntsman
Автор

// Quick quiz
#include<stdio.h>
#include<string.h>
int main()
{
char first[20];
char second[20];

printf("Enter first friend name\n");
gets(first);
printf("\n");
printf("Enter second friend name\n");
gets(second);
printf("\n");
printf("%s is a friend of %s\n", first, second);
strcat(first, second);
printf("This is the concatenated output: \b %s", first, second);
return 0;
}

abhishekojha
Автор

#include<stdio.h>
#include<string.h>
int main()
{
char f1[32];
char f2[31];

char f3[]=" is friend of ";
char f4[50];

printf("First friend ");
gets(f1);

printf("Second friend ");
gets(f2);





puts(f4);


}

mayankmaurya
Автор

Thank you so much c programing ke bare me btane ke liye

ajitgautam
Автор

#include <stdio.h>
#include <string.h>

int main(){

char name1[10], name2[10];
char str[50];
printf("Enter the name of person1: ");
gets(name1);
printf("Enter the name of person2: ");
gets(name2);
strcat(name1, " is a friend of ");
strcpy(str, strcat(name1, name2));
puts(str);

return 0;
}
output:
Enter the name of person1: Ronak
Enter the name of person2: Shubham
Ronak is a friend of Shubham

ronakmaniya
Автор

quiz done sir
#include <stdio.h>
#include <string.h>
int main()
{
char s1[30];
char s2[30];
char s3[30]=" is a friend of ";
printf("Enter the first name\n");
scanf("%s", s1);
printf("Enter the second name\n");
scanf("%s", s2);
puts(strcat(strcat(s1, s3), s2));
return 0;
}

adityasaxena
Автор

// Online C compiler to run C program online
#include <stdio.h>
#include<string.h>

int main() {
char s1[20], s2[20];
printf("enter the input to string s1 : ");
gets(s1);
printf("\nenter the input to string s2 : ");
gets(s2);
printf("\nyour enter strings are as below :");
puts(s1);
printf("\n");
puts(s2);
printf("\nthe output is :\n");
puts(s1);
printf(" is friend of ");
puts(s2);

return 0;
}

namanjain
Автор

Love 🥰 you harry bhai from bengal.
Here is my code.
// allow user to enter two strings and then concatenate them by saying that
//str1 is a friend of str2
#include<stdio.h>
#include<string.h>

int main()
{
char s1[25];
char s2[30];
printf("Please enter two strings:\n");
gets(s1);
gets(s2);
printf("%s is a friend of %s\n", s1, s2);
puts(strcat(s1, s2));

return 0;
}

subhankarkanrar
Автор

#include <stdio.h>
#include <string.h>
int main()
{
char s1[22];
char s2[22];
char s3[22];

printf("Enter first Name \n");
gets(s1 );
printf("Enter second Name \n");
gets(s2 );
printf("relation \n");
gets(s3 );

puts(strcat(s1, strcat(s3, s2)));


return 0;
}

balakp
Автор

#Quick Quiz: solution:

#include <stdio.h>
#include <string.h>
int main()
{
char str1[10];
char str2[10];
char str3[10];
// printf("Concatinating the name of two friends!");
printf("Please type you name:\n");
gets(str1);
puts(str1);
printf("Please type your friend's name:)\n");
gets(str2);
printf("%s Is a friend of %s", str1, str2);
// strcpy(str3, strcat(str1, str2));
// puts(str3);
return 0;
}

Ashish...
Автор

Answer of quiz
#include<stdio.h>
#include<string.h>
void main()
{
char st1[10], st2[10];
char s[50];
char st[]=" is friend of ";
printf("enter name of friends");
gets(st1);
gets(st2);

strcpy(s, strcat(st1, st));
strcat(s, st2);
printf("required sentence is:\n");
puts(s);
getchar();

}

CodeSprint