Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp().
The function my_strcmp() is simple compared to my_strcmp().
The above functions do very basic string concatenation and string comparison. These functions do not provide same functionality as standard library functions.
Please write comments if you find the above code incorrect, or find better ways to solve the same problem.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- strcat() vs strncat() in C++
- Difference between strncmp() and strcmp in C/C++
- strcmp() in C/C++
- Write a one line C function to round floating point numbers
- C program to print odd line contents of a File followed by even line content
- Swap two variables in one line
- Write a program that produces different results in C and C++
- Write your own memcpy() and memmove()
- lseek() in C/C++ to read the alternate nth byte and write it in another file
- Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure?
- Write a C program to print "Geeks for Geeks" without using a semicolon
- Write a C macro PRINT(x) which prints x
- When should we write our own copy constructor?
- Does C++ compiler create default constructor when we write our own?
- When should we write our own assignment operator in C++?
- Write a C program that does not terminate when Ctrl+C is pressed
- fopen() for an existing file in write mode
- Write a C program that won't compile in C++
- How to write a running C code without main()?
- Write a C program that displays contents of a given file like 'more' utility in Linux