code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//
/* Jason Boxall 1/13/97 CSC 131 Lab#5*/
/* this program inputs a name(s) and prints it(them) out backwards */
#include
#include
FILE *fout;
void main()
{
char name[20];
char *getname();/* Fuction prototype */
void switcheroo(char *);/* Fuction prototype */
fout=fopen("a:lab5out.dat","w");
strcpy(name,getname());
while(strcmp("q",name))
{
switcheroo(name);
fprintf(fout,"\n");
strcpy(name,getname());
}
}
char *getname()
{
char name[20];
printf("\n\nEnter in a name to print backwards or 'q' to quit: ");
gets(name);
return name;
}
void switcheroo(char *name)
{
int x,i;
x=strlen(name);
for(i=(x-1);i>=0;--i)
{
putchar(name[i]);
fprintf(fout,"%c",name[i]);
}
}
Other 172 submission(s) by this author