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;
}
Answers: 3
Computers and Technology, 23.06.2019 00:10
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
Answers: 1
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
Computers and Technology, 24.06.2019 04:30
What is the process in which the software development team compiles information to determine the final product
Answers: 1
Computers and Technology, 24.06.2019 13:00
Why should you evaluate trends when thinking about a career path?
Answers: 1
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...
History, 28.08.2019 16:10
Biology, 28.08.2019 16:10
English, 28.08.2019 16:10
Mathematics, 28.08.2019 16:10
Mathematics, 28.08.2019 16:10
Mathematics, 28.08.2019 16:10