Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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; }
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
Step: 1
Get Instant Access to Expert-Tailored 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