I don't understand how pointers work, I think the trouble I am running into is using chars for the variables. In any case I am trying to move a few variables out of one function ReverseIt() to another function Write() in any case I am running into a million errors.
Header:
Driver:Code:#include <iostream> #include <string> using namespace std; //Prototypes pointing to multiple functions void Obj_Screen(); //must pass Reverse from ReverseIt and to Driver void ReverseIt(char *Reverse, char *Name); void Write(char Reverse, char Name);
Functions:Code:#include <iostream> #include <string> #include "Prototypes.h" using namespace std; int main() { char Reverse[50], Name[50]; Obj_Screen(); //recieve here ReverseIt(&Reverse, &Name); Write(Reverse, Name); }
Code:#include <iostream> #include <string> #include "Prototypes.h" using namespace std; void Obj_Screen() { cout << "This Program will completly reverse the words you input into it."; cout << "Why don't you try typing your name in first! \n\n"; system("pause"); system("cls"); } void ReverseIt(char *Reverse, char *Name) { int i; //pointer reated here, not sure if thats correct. getline(cin, *Name); for (i=*Name.size(); i>0; --i) { //need to bring this to main() *Reverse=*Reverse+*Name[i]; } } void Write(char Reverse, char Name) { cout << "Your name in Reverse is "<<Resverse <<"!"; }




Reply With Quote