Question
Having problems running this portion of the code in C. Keep getting error saying: kstring.c:46:8: error: conflicting types for kstrlen size_t kstrlen(char kstring[]) // function
Having problems running this portion of the code in C. Keep getting error saying:
kstring.c:46:8: error: conflicting types for kstrlen size_t kstrlen(char kstring[]) // function to return length of string
Function def. in header file: size_t kstrlen(char str);
Typedef:
typedef struct { char *data; size_t length; } kstring;
Function:
size_t kstrlen(char kstring[]) // function to return length of string { int j = 0; while (kstring[j] != '\0') //using while loop for reading every character of string { ++j; } return j; }
Function call in main:
kstring kstr; kstring name; char kstring[50]; int pos; size_t kstring_length; char str_pos; int pos_1; char s; char *input; printf(" Enter a string "); fgets(kstring, sizeof(kstring), stdin); kstring_length= kstrlen(kstring); printf("The length of given string is %d ", kstring_length);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started