forked from kautukraj/Lab6C
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2Copy.c
More file actions
32 lines (29 loc) · 888 Bytes
/
2Copy.c
File metadata and controls
32 lines (29 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* implementing strcmp using dynamic memory allocation in C */
/* Author : Kautuk Raj */
#include <stdio.h>
#include <stdlib.h>
void my_strcat(); // function prototype
void my_strcat()
{
int i = 0, flag = 0;
char* p1 = (char*)malloc(255 * sizeof(char)); /* allocating char pointer of size 255 to implement string */
char* p2 = (char*)malloc(255 * sizeof(char));
scanf("%[^' '] %s", p1, p2);
while (*(p1 + i) != '\0' || *(p2 + i) != '\0') /* till we reach the end of the string */
{
if (*(p1 + i) != *(p2 + i)) /* checking if each char position element is equal or not */
{
flag = 1;
break;
}
i++;
}
printf("%d\n", flag);
free(p1); /* freeing up the memory space allocated */
free(p2);
}
int main()
{
my_strcat(); // calling the function
return 0;
}