about the last program...
Hey guys, I have a question about the last program that I asked about. It's below under the livejournal cut, and I can't get it to print anything out to the screen, no matter where I put the cout statement. Our teacher was trying to explain it to me, but parts of it don't make sense the way she explains things. She says there might be something wrong with the while statements. Could anyone tell me what I need to change around to make it work and how it works if possible?
Thanks =0)
//Batty
//11-30-04
//to reverse a string
#include
Thanks =0)
//Batty
//11-30-04
//to reverse a string
#include
[Error: Irreparable invalid markup ('<iostream.h)>') in entry. Owner must fix manually. Raw contents below.]
Hey guys, I have a question about the last program that I asked about. It's below under the livejournal cut, and I can't get it to print anything out to the screen, no matter where I put the cout statement. Our teacher was trying to explain it to me, but parts of it don't make sense the way she explains things. She says there might be something wrong with the while statements. Could anyone tell me what I need to change around to make it work and how it works if possible?
Thanks =0)
<lj-cut text="the backwards text program">
//Batty
//11-30-04
//to reverse a string
#include <iostream.h)
#include <iomanip.h)
#include <string.h)
int main ()
{
char string1[10]; //character array to hold first string
char stringreverse[10];
int i=0; //hold string length
int k=0; //begin our string reversal
int null_length=0;
int end_string =0;
strcpy(string1, ""); // makes character arrays empty
strcpy(stringreverse, "");
cout << "Please enter a string of text of ten characters or less." << '\n';
cin >> string1;
while(string1[i] != stringreverse[i]) //find the length of the literal string
{i++;}
null_length = i-1;
end_string = i-2;
k=0;
while (k != end_string)
{
stringreverse[k]=string1[end_string];
k=k++;
end_string--;
}
stringreverse[null_length] ='\0';
cout<< stringreverse << endl;
return 0;
}
</lj-cut>
Thanks =0)
<lj-cut text="the backwards text program">
//Batty
//11-30-04
//to reverse a string
#include <iostream.h)
#include <iomanip.h)
#include <string.h)
int main ()
{
char string1[10]; //character array to hold first string
char stringreverse[10];
int i=0; //hold string length
int k=0; //begin our string reversal
int null_length=0;
int end_string =0;
strcpy(string1, ""); // makes character arrays empty
strcpy(stringreverse, "");
cout << "Please enter a string of text of ten characters or less." << '\n';
cin >> string1;
while(string1[i] != stringreverse[i]) //find the length of the literal string
{i++;}
null_length = i-1;
end_string = i-2;
k=0;
while (k != end_string)
{
stringreverse[k]=string1[end_string];
k=k++;
end_string--;
}
stringreverse[null_length] ='\0';
cout<< stringreverse << endl;
return 0;
}
</lj-cut>
