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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!