Skip to content

Commit 25d5335

Browse files
committed
Create problem35
1 parent 55f4c53 commit 25d5335

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

problem35

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Solution by Pavithra B, 111712205071, IT dept.
2+
3+
4+
Actually this creates 50 bytes which may cause memory leak. therefore after printing p, we should free the variable p and q(i.e.. free(p),free(q)).
5+
6+
It may cause ExitFailure 9 which may arise due to memory exhaution
7+
8+
correct code:
9+
10+
#include<stdio.h>
11+
#include<string.h>
12+
main()
13+
{
14+
char *p,*q;
15+
p=(char *)malloc(25);
16+
q=(char*) malloc(25);
17+
strcpy(p,"amazon" );
18+
strcpy(q,"hyd");
19+
strcat(p,q);
20+
printf("%s",p);
21+
free(p);
22+
free(q);
23+
return 0;
24+
}
25+
26+
Output:
27+
amazonhyd

0 commit comments

Comments
 (0)