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
Lab6 v0.5 Sin,cos,tan,cot
co_4
B_141209_EsPrimo
MATRICES DE CARACTERES
ele709 lab 3.2
B_141209_EsMayor
20171127_ARRAY_PRIMOS
Area and Volume coding
Project 4 v1
18BCE2182 ASSESS_2 Q2