Cornedbee would probably break a candy dish over your head for this...
Errors in red
Code:
char choice[2], choice1[2];
choice1[2]='y'; /* Buffer overflow here. */
........................
printf("Another? (y/n)");
scanf("%s", choice); /* This isn't wrong, but its not customarily how one would do it */
while(strncmp(choice,choice1,1)==0) /* Odd choice */
{ .......................
printf("Another? (y/n)");
scanf("%s", choice);
}
system("PAUSE");
return 0;
;
So lets see why I am breaking out the red. When you make an array your arrays are going to be filled with undefined data at first, and they are also going to start at index 0. So they go from 0 to n-1. So if you declare an array like this:
Example:
Then you can access from 0 to 49 (which is 50 - 1). If you are only comparing one char of string a and one char of string b, why not just directly compare them?