Hi, this is my first post on this site, so hopefully this is correct way of doing things.
I have started typing a piece of code that allows input of two strings that will be placed together. However i have come across this error : "'mystrcat' : cannot convert parameter 1 from 'char [80]' to 'char'" and cant figure out how to correct it.
Any help appreciated.
Code:
#include "stdafx.h"
#include "ctype.h"
#include "string.h"
char mystrcat(char, char);
int main()
{
char string1[80], string2[80];
for (;;)
{
printf("Enter string1: ");
scanf("%s", &string1);
if (!strcmp(string1, "done"))
break;
printf("Enter string2: ");
scanf("%s", &string2);
printf("String1: %s String2: %s\n", string1, string2);
printf("Returned string : %s\n", mystrcat(string1, string2));
printf("String1: %s String2: %s\n", string1, string2);
}
}
char *mystrcat(char *s, char *p)
{
size_t i,j;
for (i = 0; s[i] != '\0'; i++);
for (j = 0; p[j] != '\0'; j++)
s[i+j] = p[j];
s[i+j] = '\0';
return s;
}