![subject](/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;
}
![ansver](/tpl/images/cats/User.png)
Answers: 3
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 18:00
Budgets you to do all of the following expect a) send frivolously b) avoid over spending c) gain financial independence d) examine your priorities and goals
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 00:40
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why.a.) student.course.callnum = "csc230"; b.) cin > > student.name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student.name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist.course.credits = 3; j.) course = studenttype.course;
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 01:00
Complete the sentence about a presentation delivery method
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 07:00
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
You know the right 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
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/obshestvoznanie.png)
![question](/tpl/images/cats/istoriya.png)
History, 31.01.2020 06:46
![question](/tpl/images/cats/en.png)
English, 31.01.2020 06:46
![question](/tpl/images/cats/mat.png)
Mathematics, 31.01.2020 06:46
![question](/tpl/images/cats/istoriya.png)
History, 31.01.2020 06:46
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/himiya.png)
Chemistry, 31.01.2020 06:46
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/istoriya.png)
History, 31.01.2020 06:46
![question](/tpl/images/cats/himiya.png)
Chemistry, 31.01.2020 06:46