I need help putting this program I have done that works correctly into Sub procedures.
This part below from the program i need in one sub procedure for the input:Code:#include<stdio.h> #include<string.h> /* Needed To Do Copy, Reverse & Compare */ int main() { /* Declare Variables */ char vectorEntered[21]; /* Size = 21 because \0 takes up one space */ char vectorBackwards[21]; /* Size = 21 because \0 takes up one space */ /* Input From User */ printf("\n Enter A Vector (String):= "); gets(vectorEntered); /* Changing The Vector, Backwards */ strcpy(vectorBackwards,vectorEntered); /* Copy The Vector Entered to Vector Backwards */ strrev(vectorBackwards); /* Reverse Vector Backwards */ /* Compare The Vectors And Output Answer */ if(strcmp(vectorEntered,vectorBackwards)==0) /* Compare The Two Variables A Sucess*/ { printf("\n The Vector Entered, \"%s\", is the same forwards as backwards!",vectorEntered); } else /* Compare The Two Variables Not A Sucess */ { printf("\n The Vector Entered, \"%s\", is not same forwards as backwards!",vectorEntered); } getchar(); getchar(); return 0; }
I need another for:Code:printf("\n Enter A Vector (String):= "); gets(vectorEntered);
I also need one for:Code:strcpy(vectorBackwards,vectorEntered); /* Copy The Vector Entered to Vector Backwards */ strrev(vectorBackwards); /* Reverse Vector Backwards */
Please Help, I dont know how to make sub procdures work properly in this program.Code:if(strcmp(vectorEntered,vectorBackwards)==0) /* Compare The Two Variables A Sucess*/ { printf("\n The Vector Entered, \"%s\", is the same forwards as backwards!",vectorEntered); } else /* Compare The Two Variables Not A Sucess */ { printf("\n The Vector Entered, \"%s\", is not same forwards as backwards!",vectorEntered); }
I have also attached the program as well.



LinkBack URL
About LinkBacks


