Can someone tell me what's wrong with my code? I've looked extensively at the error messages VS gives me, but I'm at a loss. I've attaches error messages for more info.
//Inclusion of necessary header files
#include <stdio.h>
#include <string.h>
//String Removal function prototype
char str_check(char *, char *);
void str_remove(char*, char*);
int isPrefix(char* list1, char* list2);
//Entry point for header files, pre-processor directives, and function prototypes
int main()
{
//Necessary variable declarations
char list1[500];
char list2[20];
//Input prompt and input function for first string
printf("Please enter a string of up to 500 characters for first array.\n");
*list1 = getchar();
//Input prompt and input function for second string
printf("Please enter a string of up to 20 characters for second array.\n");
*list2 = getchar();
//String Removal function call assigns function output to a third array and uses string function to display output
*list1 = str_check(list1, list2);
puts(list1);
//Exit sequence
return 0;
}
//String check function definition
char str_check(char* list1, char* list2)
{
//Temporary character pointer declarations and for loop control variables
char *ptr1=list1, *ptr2=list2;
int i, j, k;
//Loop checks both array elements for concurrent characters using isPrefix function, checks for concurrent string segments if one is found, call string removal function
for (i = 0; i < strlen(list1); i++)
{
if (isPrefix(ptr1+i, ptr2)==1)
{
str_remove(ptr1+i, ptr2);
}
}
return;
}
//isPrefix function definition checks for string occurences
int isPrefix_1 (char* ptr1, char* ptr2){
int i=0;
while(*(ptr1 + i) != '\0')
{
if(*(ptr1 + i) != *(ptr2 + i))
{
return 0;
}
i++;
}
return 1;
}
void str_remove(char* ptr1, char* ptr2)
{
int offset = strlen(ptr2);
int i=0;
for(i=0;i<(strlen(ptr1)-strlen(ptr2));i++)
{
*(ptr1+i) = *(ptr1+i+offset);
}
*(ptr1+i+offset) ='\0';
}
ERROR MESSAGES:
: warning C4018: '<' : signed/unsigned mismatch
: warning C4033: 'str_check' must return a value
: warning C4101: 'k' : unreferenced local variable
: warning C4101: 'j' : unreferenced local variable
: warning C4018: '<' : signed/unsigned mismatch
: warning C4716: 'str_check' : must return a value
: fatal error LNK1120: 1 unresolved externals