|
-
Aug 4th, 2001, 11:38 PM
#1
Thread Starter
Frenzied Member
String Reverse...
I'm trying to create a string reverser, but the program doesn't read out the result....can anyone tell me what I'm doing wrong...
Code:
#include <iostream.h>
#include <windows.h>
void main(){
char TempString[255];
char TheString[255];
int StringLen;
cout<<"Please enter string to reverse: ";
cin>>TempString;
StringLen = strlen(TempString);
for(int a = 0; a > 255; a++)
{
TheString[a] = TempString[StringLen - 1];
}
for(int index = 0; index > 255; index++)
{
cout<<TheString[a];
}
}
-
Aug 4th, 2001, 11:54 PM
#2
Member
CyberCarsten
The following line
// do while a is greater than 255, but a equals zero therefore wouldn’t do anything.
for(int a = 0; a > 255; a++)
should read
for(int a = 0; a < 255; a++)
HTH
hmm
P.S After some thought
#include <iostream.h>
#include <windows.h>
void main(){
char TempString[255];
char TheString[255];
int StringLen;
int a;
int pause;
cout<<"Please enter string to reverse: ";
cin>>TempString;
StringLen = strlen(TempString);
for(int a = 0; a < 255; a++)
{
TheString[a] = TempString[StringLen -a];
}
for(int index = 0; index < StringLen +1 ; index++)
{
cout<<TheString[index];
}
cin >>pause;
}
Last edited by hmm; Aug 5th, 2001 at 12:11 AM.
-
Aug 5th, 2001, 12:11 AM
#3
Thread Starter
Frenzied Member
Thanks! 
Now I got the result, but it's not letters...it's just alot of |[]
????
-
Aug 5th, 2001, 12:13 AM
#4
Thread Starter
Frenzied Member
It works!! Thank you very much!
-
Aug 5th, 2001, 12:16 AM
#5
Member
CyberCarsten
Have a look at the p.s of my first post ( I was modifying it has you were reading it ). I've changed some other parts
hmm
-
Aug 5th, 2001, 01:38 AM
#6
Thread Starter
Frenzied Member
It works perfect! Thanks!
-
Aug 5th, 2001, 02:00 AM
#7
Member
-
Aug 5th, 2001, 04:33 AM
#8
Thread Starter
Frenzied Member
Hehe! I feel the same way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|