Originally Posted by
timeless
thanks so much
works perfect.
Now that you have it working, why don't you try to refine it...
Code:
char goagain(char loop)
{
printf(" would you like to enter another string? y or n:\n ");
scanf("%c", &loop);
return(loop);
}
You aren't using the passed in value inside the function, so there's no need to pass in a value.
It's bad ju ju to use a variable passed in to hold the results of a calculation, especially one done by pointers.
So get rewrite the function to not take any parameters and declare a local variable to hold the result of scanf().
Second returning the character works, but it might be better to return true or false (1 or 0).
Once you have it doing that, you can move the function call directly into your while statement...
Code:
int goagain( void )
{ char loop;
printf(" would you like to enter another string? y or n:\n ");
scanf(" %c", &loop);
return tolower(loop) == 'y'; // returns true if y or Y false for everything else
}
// in main
do
{ readin(str);
rot13(str);
print(str);
}while(goagain());
Half the fun of programming is simplifying and cleaning up code... the time to start forming these good habits is when you are just starting out. The alternative is that later on you will spend half your time fixing up after bad habits...