User Tools

Site Tools


c:c_reverse

This is an old revision of the document!


C - C++ Reverse

#include <iostream>
#include <string>
#include <cassert> 
#include <algorithm> // For reverse algorithm
using namespace std;
 
int main()
{
  char array1[] = "abc";
  int N1 = strlen(array1);
  reverse(&array1[0], &array1[N1]);
  assert (string(array1) == "cba");
  return 0;
}
c/c_reverse.1507801834.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki