saving . . . saved i compiled it without any errors but when i ran it i got this error. has been deleted. i compiled it without any errors but when i ran it i got this error. has been hidden .
i compiled it without any errors but when i ran it i got this error.
Title
Question
code : -
#include<stdio.h>
#include<string.h>
int main()
{
char str1 [] = "best";
char str2 [] = "bus";
   printf("%s", strcat(str1, str2));
   return 0;
}

In terminal -
$ gcc strcat1.c -o strcat (without any errors)
$ ./strcat

output : -
*** stack smashing detected ***: terminated

Aborted (core dumped)


C-and-Cpp String-Library-Functions 06-07 min 30-40 sec 25-01-22, 2:33 p.m. Ravi_Ns

Answers:

Please try one more time. This code is running without any errors.
25-01-22, 5:11 p.m. hbammkanti

25-01-22, 8:11 p.m. Ravi_Ns

Login to add comment


corrected code : -

#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}

note: strcat concatenate fist and second string and store data in first string.

*** stack smashing detected ***: terminated
This error occurs because of limited buffer memory that is there is not enough memory for both printf() and strcat(str1, str2) statements at same time.
25-01-22, 8:49 p.m. Ravi_Ns


#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}
12-08-24, 3:26 p.m. Nikki5D4


#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}
12-08-24, 4:08 p.m. 238T1A05D3


#include<stdio.h>
#include<conio.h>
void main()
{
char s1[10]="Best";
char s2[10]="Bus";
printf("concatenated string of %s and %s is %s",s1,s2,strcat(s1,s2));
getch();
}
output :
concatenated string of Best and Bus is BestBus
12-08-24, 4:18 p.m. 238T1A05D9


#include<stdio.h>
#include<conio.h>
void main()
{
char s1[10]="Best";
char s2[10]="Bus";
printf("concatenated string of %s and %s is %s",s1,s2,strcat(s1,s2));
getch();
}
16-08-24, 5:09 p.m. 238T1A05F5


#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}
19-08-24, 2:18 p.m. Shalini_09


#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}
19-08-24, 2:18 p.m. Shalini_09


#include<stdio.h>
#include<conio.h>
void main()
{
char str1[10]="best";
char str2[10]="bus";
printf("%s",strcat(str1,str2);
getch();
return 0;
}
output
bestbus


19-08-24, 2:37 p.m. 238T1A05G7


#include<stdio.h>
#include<string.h>
int main()
{
char str1 [10] = "best";
char str2 [10] = " bus";
strcat(str1, str2);
printf("%s\n", str1);
return 0;
}
19-08-24, 3:26 p.m. nasreensk2005@gmail.com


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[10]="best";
char str2[10]="bus";
printf("%s",strcat(str1,str2));
getch();
}
output:
bestbus

19-08-24, 4:08 p.m. 238T1A05G1


Log-in to answer to this question.