Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW22
// Stub program for Problem 2 HW 2 Fall 2016 #include <stdio.h> #define SIZE 30 #define ERROR -1 ////////////////////////////////////////////////////////////////////// // Function name: reverseString // // Description: Reverses the order of the characters in a string. // // Input/Output parameters: // *str, a pointer to the string whose characters are to be reversed, // the string is reversed in place and returned via the same // pointer. // // Returns: // void reverseString(char* str) { // Your code goes here! int length= 0; while(str[length] != '\0'){ length++; } char temp; int i=0; int j=0; j= length-1; while(i<j){ temp = str[i]; str[i] = str[j]; str[j] = temp; i++; j--; } } int main(void) { // my array for the string char myString[SIZE]; printf("\n*** Stub program for Problem 2 -- reverseString ***\n\n"); // First read in an input string if (fgets(myString, SIZE, stdin)) { // input has worked, print out the original string printf("Read in the string \"%s\".\n\n",myString); // Call your routine reverseString(myString); // Print out the result printf("After function call the string is \"%s\".\n\n",myString); } else { printf("Error reading in the string!\n"); } return 0; }
run
|
edit
|
history
|
help
0
loop
a weird way to print hello, world! hmm...
11
Project 3 Part 1 v1.4
th
CharacterInput
struct
thermal_containers
co_4
Sunday assignment v2