Question: how do I use strlen and strcpy (can't use strncpy) to split string in this function void split_string(char *str, char *string_1, char *string_2) ------------------- #include

how do I use strlen and strcpy (can't use strncpy) to split string in this function

void split_string(char *str, char *string_1, char *string_2)

-------------------

#include #include

void split_string(char *str, char *string_1, char *string_2) { int len = strlen(str) / 2; strcpy(string_1, str); strcpy(string_2, str); }

int main() { char str[100]; fgets(str, 100, stdin); int lenth = (strlen(str) - 1) / 2; char str1[lenth], str2[lenth];

split_string(str, str1, str2);

printf("%s", str1); printf("%s", str2); return 0; }

how do I use strlen and strcpy (can't use strncpy) to split

gr120160213@cspro:$ ./a.out input str : 2016CPROGRAMMING [2016CPROGRAMMING] -> [2016CPRO] [GRAMMING] gr120160213@cspro:$ ./a.out input str : hello [hello]- [he] [11] gr 120160213@cspro: $ ./a.out input str : Thank you Thank you] -[Than]_[k yo]

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!