Answered step by step
Verified Expert Solution
Link Copied!

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; }

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago