-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6365a49
commit 080e59c
Showing
5 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |