I do not understand what happens when you have more than one for statements in the same block! I am messing around trying to make a program that reverses whatever you type in (I did this type of thing in class, last year for VB.net), but so far it is not working. I just reworked this before I posted it, I think it may work now:
Code:
#include<iostream>
#include <cstdlib>
using namespace std;
int main() {
char tar [10];
char rat [10];
int length, i, b;
length = strlen(tar);
cout << "Enter a string: ";
cin.get(tar);
for(i = 0; i < (length -1); i++){
for(b = length; b >= 0; b--)
rat[i] = tar[b];
}
cout << "Your string reversed is: " << rat << i << ' ' <<b;
return 0;
}
And the error I get:
.\hypotenuse.cpp(11) : error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem &)' : cannot convert parameter 1 from 'char [10]' to 'char &'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
Don't mind the strange file name, I just reuse the same file for screwing around, to prevent a massive directory of useless programs. BTW I give my variables and that strange names because I'm to lazy to think up a descriptive name, nor do I care, after all, it's not like anyone else is going to use this (I'm not making an application or anything :P)