subject

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;

}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:40
When running anti-virus software , what could be a reason where recipitent is not guaranteed that data being streamed will not get interrupted?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
question
Computers and Technology, 23.06.2019 20:50
3.11.3 quiz: comparing and analyzing function typesquestion 4 of 102 pointswhat can you say about the y-values of the two functions f(x) = 3x2-3 andg(x)=2* - 3?
Answers: 2
question
Computers and Technology, 23.06.2019 21:30
To move a file or folder in microsoft windows, you can click and hold down the left mouse button while moving your mouse pointer to the location you want the file or folder to be, which is also known as.
Answers: 3
You know the right answer?
Add the following functions to the code:
oddsOnly - this function takes a string as an argumen...
Questions
Questions on the website: 13722361