Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Problem Statement - output writing example strcpy, strcat
Write the output of the following program.
TC++ #2649
Solution
Run Output
World 18
char str1[]=”World”; //Initialised with 5 characters of the rod World char str2[20]; //Decalred array of size 20. strcpy(str2,str1); //str2 will contain 5 characters of str1 strcat(str2,” is beautiful”); //str2 will be concatenated by 13 characters of given string.
cout<<str1<<” “<<strlen(str2);
So this will print World 18 .
Common Errors
In such codes watch carefully the size of array and the functions used before printing.