Setting A Reversed String as a New String

I can't do it. Notes: I cannot use the <string> library, i can only use the <lvp\string.h> library. I'm in a highschool c++ course, and have been programming for less than a year.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

/* Project Palindrome
   by Jacob Wright 2-21-13 */

#include <iostream.h>
#include <lvp\string.h>
#include <stdlib.h>

//________________________________

void assimilate(String simstring); //Removes capitalization differences and punctiation from simstring

//________________________________

void reverse(String revstring); //Reverses the string

//________________________________

void compare(String oristring, String newstring); //Tests if both strings are the same, and outputs

//________________________________

int main()
{
	String input;
	cout << "\n\n\n\n\n\t\t Input a String to be tested: ";
	cin >> input;
	cout << flush;
	system("cls");
	cout << "\n\n\n\n\n";
	assimilate(input);
	cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t ";
	return(0);
}

//_________________________________

void reverse(String revstring)
{
	cout << "\n\n\n\t\t Backwards String: ";
	for (int C=revstring.length()-1; C>=0; C--)
	{
		cout << revstring[C];
	}
	cout << "\n\n" << revstring;
}

//__________________________________

void assimilate(String simstring)
{
	for (int c=0; c<simstring.length(); c++)
	{
		if ((simstring[c]>='a') && (simstring[c]<='z'))
			simstring[c]=simstring[c]-'a'+'A';
	}

	cout << "\t\t Original String: " << simstring;
	reverse(simstring);
}

//___________________________________

void compare(String oristring, String newstring)
{}






Last edited on
Topic archived. No new replies allowed.