![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 05.05.2020 02:39, anyone9122
Add the following functions to the code:
oddsOnly - this function takes a string as an argument and it modifies this string in place (it does not return with the return statement) so that it deletes all characters that occupied even positions in the original string by shifting the characters that originally occupied odd positions. For example, if "hello there" were a parameter, then the updated string after the call to this function in the calling block would contain: "el hr". Don’t forget about the null character at the end of C strings and that strings in C could be simply treated as arrays of characters. Test this function by calling it from main.
Once the program runs properly, check for memory leaks and memory errors with Valgrind and apply more fixes, as needed
#include
#include
#include
char* repeated (char* original, int n);
int main(void) {
char *str = repeated("bon", 2);
printf("%s\n", str);
free(str);
char *str = repeated("bon", 3);
printf("%s\n", str);
free(str);
char *str = repeated("bon", 4);
printf("%s\n", str);
free(str);
return 0;
}
char* repeated (char* original, int n) {
int i, length = strlen(original);
char* newString = malloc (sizeof(char) * length * n + 1);
char* helper = newString;
for (i = 0; i < n; i++) {
strcpy( helper, original);
helper = helper + length;
}
return newString;
}
![answer](/tpl/images/cats/otvet.png)
Answers: 3
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 07:00, MissSmartyPants88
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 20:00, shadow6728g
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 17:30, leenzazou98241
What is the next step if your volume does not work on computer
Answers: 2
Do you know the correct answer?
Add the following functions to the code:
oddsOnly - this function takes a string as an argumen...
oddsOnly - this function takes a string as an argumen...
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/biologiya.png)
Biology, 28.09.2019 06:00
![Konu](/tpl/images/cats/es.png)
![Konu](/tpl/images/cats/ekonomika.png)
Business, 28.09.2019 06:00
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 28.09.2019 06:00
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/geografiya.png)