reverse from pointer
// this takes a pointer to a char array and the length of array as params
//http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/
#include <cstring>
#include <iostream>
using namespace std;
void reverse (char *strx, int size)
{
//loop through array backward and print each character
for (int x=size-1; x>=0; x--)
cout<<strx[x];
}
//define array
/*
int main()
{
const int length =30;
char name[length];
//prompt for string
cout <<"enter a string\n";
cin.getline(name, length);
//pass its length and the array as params to function
reverse (name,strlen(name));
cin.ignore();
}
*/
//http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/
#include <cstring>
#include <iostream>
using namespace std;
void reverse (char *strx, int size)
{
//loop through array backward and print each character
for (int x=size-1; x>=0; x--)
cout<<strx[x];
}
//define array
/*
int main()
{
const int length =30;
char name[length];
//prompt for string
cout <<"enter a string\n";
cin.getline(name, length);
//pass its length and the array as params to function
reverse (name,strlen(name));
cin.ignore();
}
*/