Reverse a string : String « Data Type « Visual C++ .NET






Reverse a string

 

#include "stdafx.h"
using namespace System;

void main()
{

    array<int>^ a = gcnew array<int>(4);
    array<String^>^ b = gcnew array<String^>(4);

    for (int i = 0; i < a->Length; i++)
    {
        a[i] = i;
    }

    for (int i = 0; i < b->Length; i++)
    {
        b[i] = a[i].ToString();
    }

    for (int i = 0; i < b->Length; i++)
    {
        Console::WriteLine(b[i]);
    }

    Console::WriteLine();
    Array::Reverse(b);
    for (int i = 0; i < b->Length; i++)
    {
        Console::WriteLine(b[i]);
    }
}

   
  








Related examples in the same category

1.String Literals
2.Create a String
3.Create some strings
4.Output a string
5.Insert into a string
6.Remove text from strings
7.Create a copy, then concatenate new text
8.Replace stuff in a concatenated string
9.Compare two strings with String::Compare
10.Use static method String::Compare to compare two strings
11.Compare strings for equality with ==
12.Compare strings for equality with String::Equals
13.Compare strings for equality with String::ReferenceEquals
14.Using string for each loop to output chars
15.String operator plus
16.Convert back to a String using the String constructor that takes a Unicode character array.
17.Convert String to char array
18.Convert String to char pointer
19.Convert text read from stdin to uppercase and write to stdout