Skip to content

Commit

Permalink
Released assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrodCoding committed Nov 16, 2022
1 parent 6365a49 commit 080e59c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions 18_reverse_str/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reverse
2 changes: 2 additions & 0 deletions 18_reverse_str/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reverse: reverse.c
gcc -o reverse -pedantic -std=gnu99 -Wall -Werror reverse.c
15 changes: 15 additions & 0 deletions 18_reverse_str/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
For this problem, you will write the function

void reverse(char * str)

in the provided reverse.c file. This function should reverse the string
passed into it (that is, if given "abc", it should change the contents
of that string to read "cba"). Note that this function's return type
is "void"---it modifies the string passed into it in place.

We have provided a main function which you can use to test your
reverse function (do you recognize the quotations?). The correct
output for your program can be found in reverse_ans.txt, so you can
diff your program's output against it.

Submit your reverse.c file for grading.
23 changes: 23 additions & 0 deletions 18_reverse_str/reverse.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void reverse(char * str) {
//WRITE ME!
}

int main(void) {
char str0[] = "";
char str1[] = "123";
char str2[] = "abcd";
char str3[] = "Captain's log, Stardate 42523.7";
char str4[] = "Hello, my name is Inigo Montoya.";
char str5[] = "You can be my wingman anyday!";
char str6[] = "Executor Selendis! Unleash the full power of your forces! There may be no tomorrow!";
char * array[] = {str0, str1, str2, str3, str4, str5, str6};
for (int i = 0; i < 7; i++) {
reverse(array[i]);
printf("%s\n", array[i]);
}
return EXIT_SUCCESS;
}
7 changes: 7 additions & 0 deletions 18_reverse_str/reverse_ans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

321
dcba
7.32524 etadratS ,gol s'niatpaC
.ayotnoM oginI si eman ym ,olleH
!yadyna namgniw ym eb nac uoY
!worromot on eb yam erehT !secrof ruoy fo rewop lluf eht hsaelnU !sidneleS rotucexE

0 comments on commit 080e59c

Please sign in to comment.