Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW22
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
// 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; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.12 sec, absolute running time: 10.04 sec, cpu time: 0 sec, memory peak: 0 Mb, absolute service time: 10,17 sec
edit mode
|
history
|
discussion
Error(s):
Process killed, because it ran longer than 10 seconds.